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

Side by Side Diff: ash/wm/base_layout_manager_unittest.cc

Issue 10883069: Added restore functionality for maximize full/left/right (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit test failure Created 8 years, 3 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
« no previous file with comments | « ash/wm/base_layout_manager.cc ('k') | ash/wm/custom_frame_view_ash_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base_layout_manager.h" 5 #include "ash/wm/base_layout_manager.h"
6 6
7 #include "ash/screen_ash.h" 7 #include "ash/screen_ash.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // Restore it. 170 // Restore it.
171 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 171 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
172 // It should have the default maximized window bounds, inset by the grid size. 172 // It should have the default maximized window bounds, inset by the grid size.
173 int grid_size = ash::Shell::GetInstance()->GetGridSize(); 173 int grid_size = ash::Shell::GetInstance()->GetGridSize();
174 gfx::Rect max_bounds = 174 gfx::Rect max_bounds =
175 ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()); 175 ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window.get());
176 max_bounds.Inset(grid_size, grid_size); 176 max_bounds.Inset(grid_size, grid_size);
177 EXPECT_EQ(max_bounds.ToString(), window->bounds().ToString()); 177 EXPECT_EQ(max_bounds.ToString(), window->bounds().ToString());
178 } 178 }
179 179
180 // Verifies maximizing always resets the restore bounds, and similarly restoring 180 // Verifies maximizing sets the restore bounds, and restoring
181 // resets the restore bounds. 181 // restores the bounds.
182 TEST_F(BaseLayoutManagerTest, MaximizeResetsRestoreBounds) { 182 TEST_F(BaseLayoutManagerTest, MaximizeSetsRestoreBounds) {
183 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); 183 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
184 SetRestoreBoundsInParent(window.get(), gfx::Rect(10, 11, 12, 13));
185 184
186 // Maximize it, which should reset restore bounds. 185 // Maximize it, which will keep the previous restore bounds.
187 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 186 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
188 EXPECT_EQ("1,2 3x4", GetRestoreBoundsInParent(window.get()).ToString()); 187 EXPECT_EQ("1,2 3x4", GetRestoreBoundsInParent(window.get()).ToString());
189 188
190 // Restore it, which should restore bounds and reset restore bounds. 189 // Restore it, which should restore bounds and reset restore bounds.
191 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 190 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
192 EXPECT_EQ("1,2 3x4", window->bounds().ToString()); 191 EXPECT_EQ("1,2 3x4", window->bounds().ToString());
193 EXPECT_TRUE(GetRestoreBoundsInScreen(window.get()) == NULL); 192 EXPECT_TRUE(GetRestoreBoundsInScreen(window.get()) == NULL);
194 } 193 }
195 194
195 // Verifies maximizing keeps the restore bounds if set.
196 TEST_F(BaseLayoutManagerTest, MaximizeResetsRestoreBounds) {
197 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
198 SetRestoreBoundsInParent(window.get(), gfx::Rect(10, 11, 12, 13));
199
200 // Maximize it, which will keep the previous restore bounds.
201 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
202 EXPECT_EQ("10,11 12x13", GetRestoreBoundsInParent(window.get()).ToString());
203 }
204
196 // Verifies that the restore bounds do not get reset when restoring to a 205 // Verifies that the restore bounds do not get reset when restoring to a
197 // maximzied state from a minimized state. 206 // maximzied state from a minimized state.
198 TEST_F(BaseLayoutManagerTest, BoundsAfterRestoringToMaximizeFromMinimize) { 207 TEST_F(BaseLayoutManagerTest, BoundsAfterRestoringToMaximizeFromMinimize) {
199 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); 208 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
200 gfx::Rect bounds(10, 15, 25, 35); 209 gfx::Rect bounds(10, 15, 25, 35);
201 window->SetBounds(bounds); 210 window->SetBounds(bounds);
202 211
203 // Maximize it, which should reset restore bounds. 212 // Maximize it, which should reset restore bounds.
204 wm::MaximizeWindow(window.get()); 213 wm::MaximizeWindow(window.get());
205 EXPECT_EQ(bounds.ToString(), 214 EXPECT_EQ(bounds.ToString(),
(...skipping 11 matching lines...) Expand all
217 GetRestoreBoundsInParent(window.get()).ToString()); 226 GetRestoreBoundsInParent(window.get()).ToString());
218 EXPECT_TRUE(wm::IsWindowMaximized(window.get())); 227 EXPECT_TRUE(wm::IsWindowMaximized(window.get()));
219 228
220 wm::RestoreWindow(window.get()); 229 wm::RestoreWindow(window.get());
221 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); 230 EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
222 } 231 }
223 232
224 } // namespace 233 } // namespace
225 234
226 } // namespace ash 235 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/base_layout_manager.cc ('k') | ash/wm/custom_frame_view_ash_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698