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

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

Issue 255063004: Ignoring minimum size requirements for maximized windows, full screen windows and too small screens (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: The panel layout manager was also required Created 6 years, 7 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/window_state.cc ('k') | ui/aura/window.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/window_state.h" 5 #include "ash/wm/window_state.h"
6 6
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/window_state.h" 10 #include "ash/wm/window_state.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 kWorkAreaBounds.width() - 1, 123 kWorkAreaBounds.width() - 1,
124 kWorkAreaBounds.height()); 124 kWorkAreaBounds.height());
125 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); 125 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString());
126 126
127 // It should not be possible to snap a window with a maximum size. 127 // It should not be possible to snap a window with a maximum size.
128 delegate.set_minimum_size(gfx::Size()); 128 delegate.set_minimum_size(gfx::Size());
129 delegate.set_maximum_size(gfx::Size(kWorkAreaBounds.width() - 1, INT_MAX)); 129 delegate.set_maximum_size(gfx::Size(kWorkAreaBounds.width() - 1, INT_MAX));
130 EXPECT_FALSE(window_state->CanSnap()); 130 EXPECT_FALSE(window_state->CanSnap());
131 } 131 }
132 132
133 // Test that the minimum size specified by aura::WindowDelegate gets respected.
134 TEST_F(WindowStateTest, TestRespectMinimumSize) {
135 if (!SupportsHostWindowResize())
136 return;
137
138 UpdateDisplay("0+0-1024x768");
139
140 aura::test::TestWindowDelegate delegate;
141 const gfx::Size minimum_size(gfx::Size(500, 300));
142 delegate.set_minimum_size(minimum_size);
143
144 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate(
145 &delegate, -1, gfx::Rect(0, 100, 100, 100)));
146
147 // Check that the window has the correct minimum size.
148 EXPECT_EQ(minimum_size.ToString(), window->bounds().size().ToString());
149
150 // Set the size to something bigger - that should work.
151 gfx::Rect bigger_bounds(700, 500, 700, 500);
152 window->SetBounds(bigger_bounds);
153 EXPECT_EQ(bigger_bounds.ToString(), window->bounds().ToString());
154
155 // Set the size to something smaller - that should only resize to the smallest
156 // possible size.
157 gfx::Rect smaller_bounds(700, 500, 100, 100);
158 window->SetBounds(smaller_bounds);
159 EXPECT_EQ(minimum_size.ToString(), window->bounds().size().ToString());
160 }
161
162 // Test that the minimum window size specified by aura::WindowDelegate does not
163 // exceed the screen size.
164 TEST_F(WindowStateTest, TestIgnoreTooBigMinimumSize) {
165 if (!SupportsHostWindowResize())
166 return;
167
168 UpdateDisplay("0+0-1024x768");
169 const gfx::Size work_area_size =
170 ash::Shell::GetScreen()->GetPrimaryDisplay().work_area().size();
171 const gfx::Size illegal_size(1280, 960);
172 const gfx::Rect illegal_bounds(gfx::Point(0, 0), illegal_size);
173
174 aura::test::TestWindowDelegate delegate;
175 const gfx::Size minimum_size(illegal_size);
176 delegate.set_minimum_size(minimum_size);
177
178 // The creation should force the window to respect the screen size.
179 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate(
180 &delegate, -1, illegal_bounds));
181 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString());
182
183 // Trying to set the size to something bigger then the screen size should be
184 // ignored.
185 window->SetBounds(illegal_bounds);
186 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString());
187
188 // Maximizing the window should not allow it to go bigger than that either.
189 WindowState* window_state = GetWindowState(window.get());
190 window_state->Maximize();
191 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString());
192 }
193
133 // Test that setting the bounds of a snapped window keeps its snapped. 194 // Test that setting the bounds of a snapped window keeps its snapped.
134 TEST_F(WindowStateTest, SnapWindowSetBounds) { 195 TEST_F(WindowStateTest, SnapWindowSetBounds) {
135 if (!SupportsHostWindowResize()) 196 if (!SupportsHostWindowResize())
136 return; 197 return;
137 198
138 UpdateDisplay("0+0-900x600"); 199 UpdateDisplay("0+0-900x600");
139 const gfx::Rect kWorkAreaBounds = 200 const gfx::Rect kWorkAreaBounds =
140 ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(); 201 ash::Shell::GetScreen()->GetPrimaryDisplay().work_area();
141 202
142 scoped_ptr<aura::Window> window( 203 scoped_ptr<aura::Window> window(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 EXPECT_TRUE(window_state->IsMaximized()); 310 EXPECT_TRUE(window_state->IsMaximized());
250 window_state->SetStateObject(old.Pass()); 311 window_state->SetStateObject(old.Pass());
251 EXPECT_FALSE(window_state->IsMaximized()); 312 EXPECT_FALSE(window_state->IsMaximized());
252 } 313 }
253 314
254 // TODO(skuhne): Add more unit test to verify the correctness for the restore 315 // TODO(skuhne): Add more unit test to verify the correctness for the restore
255 // operation. 316 // operation.
256 317
257 } // namespace wm 318 } // namespace wm
258 } // namespace ash 319 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_state.cc ('k') | ui/aura/window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698