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

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

Issue 2067223003: Parameterize Ash unittests to pass with material design enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing Created 4 years, 6 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
« no previous file with comments | « ash/wm/window_positioner_unittest.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
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/common/wm/window_state.h" 5 #include "ash/common/wm/window_state.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/wm/window_state.h" 10 #include "ash/common/wm/window_state.h"
10 #include "ash/common/wm/wm_event.h" 11 #include "ash/common/wm/wm_event.h"
11 #include "ash/screen_util.h" 12 #include "ash/screen_util.h"
12 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_md_test_base.h"
13 #include "ash/wm/window_state_aura.h" 14 #include "ash/wm/window_state_aura.h"
14 #include "ui/aura/client/aura_constants.h" 15 #include "ui/aura/client/aura_constants.h"
15 #include "ui/aura/test/test_window_delegate.h" 16 #include "ui/aura/test/test_window_delegate.h"
16 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
17 #include "ui/display/screen.h" 18 #include "ui/display/screen.h"
18 19
19 namespace ash { 20 namespace ash {
20 namespace wm { 21 namespace wm {
21 namespace { 22 namespace {
22 23
(...skipping 19 matching lines...) Expand all
42 void DetachState(WindowState* window_state) override {} 43 void DetachState(WindowState* window_state) override {}
43 44
44 private: 45 private:
45 WindowStateType state_type_; 46 WindowStateType state_type_;
46 47
47 DISALLOW_COPY_AND_ASSIGN(AlwaysMaximizeTestState); 48 DISALLOW_COPY_AND_ASSIGN(AlwaysMaximizeTestState);
48 }; 49 };
49 50
50 } // namespace 51 } // namespace
51 52
52 typedef test::AshTestBase WindowStateTest; 53 using WindowStateTest = test::AshMDTestBase;
54
55 INSTANTIATE_TEST_CASE_P(
56 /* prefix intentionally left blank due to only one parameterization */,
57 WindowStateTest,
58 testing::Values(MaterialDesignController::NON_MATERIAL,
59 MaterialDesignController::MATERIAL_NORMAL,
60 MaterialDesignController::MATERIAL_EXPERIMENTAL));
53 61
54 // Test that a window gets properly snapped to the display's edges in a 62 // Test that a window gets properly snapped to the display's edges in a
55 // multi monitor environment. 63 // multi monitor environment.
56 TEST_F(WindowStateTest, SnapWindowBasic) { 64 TEST_P(WindowStateTest, SnapWindowBasic) {
57 if (!SupportsMultipleDisplays()) 65 if (!SupportsMultipleDisplays())
58 return; 66 return;
59 67
60 UpdateDisplay("0+0-500x400, 0+500-600x400"); 68 UpdateDisplay("0+0-500x400, 0+500-600x400");
61 const gfx::Rect kPrimaryDisplayWorkAreaBounds = 69 const gfx::Rect kPrimaryDisplayWorkAreaBounds =
62 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); 70 display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
63 const gfx::Rect kSecondaryDisplayWorkAreaBounds = 71 const gfx::Rect kSecondaryDisplayWorkAreaBounds =
64 ScreenUtil::GetSecondaryDisplay().work_area(); 72 ScreenUtil::GetSecondaryDisplay().work_area();
65 73
66 std::unique_ptr<aura::Window> window( 74 std::unique_ptr<aura::Window> window(
(...skipping 26 matching lines...) Expand all
93 kSecondaryDisplayWorkAreaBounds.height()); 101 kSecondaryDisplayWorkAreaBounds.height());
94 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); 102 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString());
95 103
96 window_state->OnWMEvent(&snap_left); 104 window_state->OnWMEvent(&snap_left);
97 expected.set_x(kSecondaryDisplayWorkAreaBounds.x()); 105 expected.set_x(kSecondaryDisplayWorkAreaBounds.x());
98 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); 106 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString());
99 } 107 }
100 108
101 // Test how the minimum and maximum size specified by the aura::WindowDelegate 109 // Test how the minimum and maximum size specified by the aura::WindowDelegate
102 // affect snapping. 110 // affect snapping.
103 TEST_F(WindowStateTest, SnapWindowMinimumSize) { 111 TEST_P(WindowStateTest, SnapWindowMinimumSize) {
104 if (!SupportsHostWindowResize()) 112 if (!SupportsHostWindowResize())
105 return; 113 return;
106 114
107 UpdateDisplay("0+0-600x900"); 115 UpdateDisplay("0+0-600x900");
108 const gfx::Rect kWorkAreaBounds = 116 const gfx::Rect kWorkAreaBounds =
109 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); 117 display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
110 118
111 aura::test::TestWindowDelegate delegate; 119 aura::test::TestWindowDelegate delegate;
112 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( 120 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate(
113 &delegate, -1, gfx::Rect(0, 100, kWorkAreaBounds.width() - 1, 100))); 121 &delegate, -1, gfx::Rect(0, 100, kWorkAreaBounds.width() - 1, 100)));
(...skipping 15 matching lines...) Expand all
129 delegate.set_maximum_size(gfx::Size(kWorkAreaBounds.width() - 1, 0)); 137 delegate.set_maximum_size(gfx::Size(kWorkAreaBounds.width() - 1, 0));
130 EXPECT_FALSE(window_state->CanSnap()); 138 EXPECT_FALSE(window_state->CanSnap());
131 delegate.set_maximum_size(gfx::Size(0, kWorkAreaBounds.height() - 1)); 139 delegate.set_maximum_size(gfx::Size(0, kWorkAreaBounds.height() - 1));
132 EXPECT_FALSE(window_state->CanSnap()); 140 EXPECT_FALSE(window_state->CanSnap());
133 delegate.set_maximum_size(gfx::Size()); 141 delegate.set_maximum_size(gfx::Size());
134 window->SetProperty(aura::client::kCanMaximizeKey, false); 142 window->SetProperty(aura::client::kCanMaximizeKey, false);
135 EXPECT_FALSE(window_state->CanSnap()); 143 EXPECT_FALSE(window_state->CanSnap());
136 } 144 }
137 145
138 // Test that the minimum size specified by aura::WindowDelegate gets respected. 146 // Test that the minimum size specified by aura::WindowDelegate gets respected.
139 TEST_F(WindowStateTest, TestRespectMinimumSize) { 147 TEST_P(WindowStateTest, TestRespectMinimumSize) {
140 if (!SupportsHostWindowResize()) 148 if (!SupportsHostWindowResize())
141 return; 149 return;
142 150
143 UpdateDisplay("0+0-1024x768"); 151 UpdateDisplay("0+0-1024x768");
144 152
145 aura::test::TestWindowDelegate delegate; 153 aura::test::TestWindowDelegate delegate;
146 const gfx::Size minimum_size(gfx::Size(500, 300)); 154 const gfx::Size minimum_size(gfx::Size(500, 300));
147 delegate.set_minimum_size(minimum_size); 155 delegate.set_minimum_size(minimum_size);
148 156
149 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( 157 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate(
150 &delegate, -1, gfx::Rect(0, 100, 100, 100))); 158 &delegate, -1, gfx::Rect(0, 100, 100, 100)));
151 159
152 // Check that the window has the correct minimum size. 160 // Check that the window has the correct minimum size.
153 EXPECT_EQ(minimum_size.ToString(), window->bounds().size().ToString()); 161 EXPECT_EQ(minimum_size.ToString(), window->bounds().size().ToString());
154 162
155 // Set the size to something bigger - that should work. 163 // Set the size to something bigger - that should work.
156 gfx::Rect bigger_bounds(700, 500, 700, 500); 164 gfx::Rect bigger_bounds(700, 500, 700, 500);
157 window->SetBounds(bigger_bounds); 165 window->SetBounds(bigger_bounds);
158 EXPECT_EQ(bigger_bounds.ToString(), window->bounds().ToString()); 166 EXPECT_EQ(bigger_bounds.ToString(), window->bounds().ToString());
159 167
160 // Set the size to something smaller - that should only resize to the smallest 168 // Set the size to something smaller - that should only resize to the smallest
161 // possible size. 169 // possible size.
162 gfx::Rect smaller_bounds(700, 500, 100, 100); 170 gfx::Rect smaller_bounds(700, 500, 100, 100);
163 window->SetBounds(smaller_bounds); 171 window->SetBounds(smaller_bounds);
164 EXPECT_EQ(minimum_size.ToString(), window->bounds().size().ToString()); 172 EXPECT_EQ(minimum_size.ToString(), window->bounds().size().ToString());
165 } 173 }
166 174
167 // Test that the minimum window size specified by aura::WindowDelegate does not 175 // Test that the minimum window size specified by aura::WindowDelegate does not
168 // exceed the screen size. 176 // exceed the screen size.
169 TEST_F(WindowStateTest, TestIgnoreTooBigMinimumSize) { 177 TEST_P(WindowStateTest, TestIgnoreTooBigMinimumSize) {
170 if (!SupportsHostWindowResize()) 178 if (!SupportsHostWindowResize())
171 return; 179 return;
172 180
173 UpdateDisplay("0+0-1024x768"); 181 UpdateDisplay("0+0-1024x768");
174 const gfx::Size work_area_size = 182 const gfx::Size work_area_size =
175 display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size(); 183 display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size();
176 const gfx::Size illegal_size(1280, 960); 184 const gfx::Size illegal_size(1280, 960);
177 const gfx::Rect illegal_bounds(gfx::Point(0, 0), illegal_size); 185 const gfx::Rect illegal_bounds(gfx::Point(0, 0), illegal_size);
178 186
179 aura::test::TestWindowDelegate delegate; 187 aura::test::TestWindowDelegate delegate;
(...skipping 10 matching lines...) Expand all
190 window->SetBounds(illegal_bounds); 198 window->SetBounds(illegal_bounds);
191 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString()); 199 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString());
192 200
193 // Maximizing the window should not allow it to go bigger than that either. 201 // Maximizing the window should not allow it to go bigger than that either.
194 WindowState* window_state = GetWindowState(window.get()); 202 WindowState* window_state = GetWindowState(window.get());
195 window_state->Maximize(); 203 window_state->Maximize();
196 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString()); 204 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString());
197 } 205 }
198 206
199 // Test that setting the bounds of a snapped window keeps its snapped. 207 // Test that setting the bounds of a snapped window keeps its snapped.
200 TEST_F(WindowStateTest, SnapWindowSetBounds) { 208 TEST_P(WindowStateTest, SnapWindowSetBounds) {
201 if (!SupportsHostWindowResize()) 209 if (!SupportsHostWindowResize())
202 return; 210 return;
203 211
204 UpdateDisplay("0+0-900x600"); 212 UpdateDisplay("0+0-900x600");
205 const gfx::Rect kWorkAreaBounds = 213 const gfx::Rect kWorkAreaBounds =
206 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); 214 display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
207 215
208 std::unique_ptr<aura::Window> window( 216 std::unique_ptr<aura::Window> window(
209 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); 217 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100)));
210 WindowState* window_state = GetWindowState(window.get()); 218 WindowState* window_state = GetWindowState(window.get());
211 const WMEvent snap_left(WM_EVENT_SNAP_LEFT); 219 const WMEvent snap_left(WM_EVENT_SNAP_LEFT);
212 window_state->OnWMEvent(&snap_left); 220 window_state->OnWMEvent(&snap_left);
213 EXPECT_EQ(WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); 221 EXPECT_EQ(WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType());
214 gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x(), 222 gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x(),
215 kWorkAreaBounds.y(), 223 kWorkAreaBounds.y(),
216 kWorkAreaBounds.width() / 2, 224 kWorkAreaBounds.width() / 2,
217 kWorkAreaBounds.height()); 225 kWorkAreaBounds.height());
218 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); 226 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString());
219 227
220 // Snapped windows can have any width. 228 // Snapped windows can have any width.
221 expected.set_width(500); 229 expected.set_width(500);
222 window->SetBounds(gfx::Rect(10, 10, 500, 300)); 230 window->SetBounds(gfx::Rect(10, 10, 500, 300));
223 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); 231 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString());
224 EXPECT_EQ(WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); 232 EXPECT_EQ(WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType());
225 } 233 }
226 234
227 // Test that snapping left/right preserves the restore bounds. 235 // Test that snapping left/right preserves the restore bounds.
228 TEST_F(WindowStateTest, RestoreBounds) { 236 TEST_P(WindowStateTest, RestoreBounds) {
229 std::unique_ptr<aura::Window> window( 237 std::unique_ptr<aura::Window> window(
230 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); 238 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100)));
231 WindowState* window_state = GetWindowState(window.get()); 239 WindowState* window_state = GetWindowState(window.get());
232 240
233 EXPECT_TRUE(window_state->IsNormalStateType()); 241 EXPECT_TRUE(window_state->IsNormalStateType());
234 242
235 // 1) Start with restored window with restore bounds set. 243 // 1) Start with restored window with restore bounds set.
236 gfx::Rect restore_bounds = window->GetBoundsInScreen(); 244 gfx::Rect restore_bounds = window->GetBoundsInScreen();
237 restore_bounds.set_width(restore_bounds.width() + 1); 245 restore_bounds.set_width(restore_bounds.width() + 1);
238 window_state->SetRestoreBoundsInScreen(restore_bounds); 246 window_state->SetRestoreBoundsInScreen(restore_bounds);
(...skipping 20 matching lines...) Expand all
259 window->GetBoundsInScreen().ToString()); 267 window->GetBoundsInScreen().ToString());
260 EXPECT_EQ(restore_bounds.ToString(), 268 EXPECT_EQ(restore_bounds.ToString(),
261 window_state->GetRestoreBoundsInScreen().ToString()); 269 window_state->GetRestoreBoundsInScreen().ToString());
262 270
263 window_state->Restore(); 271 window_state->Restore();
264 EXPECT_EQ(restore_bounds.ToString(), window->GetBoundsInScreen().ToString()); 272 EXPECT_EQ(restore_bounds.ToString(), window->GetBoundsInScreen().ToString());
265 } 273 }
266 274
267 // Test that maximizing an auto managed window, then snapping it puts the window 275 // Test that maximizing an auto managed window, then snapping it puts the window
268 // at the snapped bounds and not at the auto-managed (centered) bounds. 276 // at the snapped bounds and not at the auto-managed (centered) bounds.
269 TEST_F(WindowStateTest, AutoManaged) { 277 TEST_P(WindowStateTest, AutoManaged) {
270 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 278 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
271 WindowState* window_state = GetWindowState(window.get()); 279 WindowState* window_state = GetWindowState(window.get());
272 window_state->set_window_position_managed(true); 280 window_state->set_window_position_managed(true);
273 window->Hide(); 281 window->Hide();
274 window->SetBounds(gfx::Rect(100, 100, 100, 100)); 282 window->SetBounds(gfx::Rect(100, 100, 100, 100));
275 window->Show(); 283 window->Show();
276 284
277 window_state->Maximize(); 285 window_state->Maximize();
278 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT); 286 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT);
279 window_state->OnWMEvent(&snap_right); 287 window_state->OnWMEvent(&snap_right);
280 288
281 const gfx::Rect kWorkAreaBounds = 289 const gfx::Rect kWorkAreaBounds =
282 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); 290 display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
283 gfx::Rect expected_snapped_bounds( 291 gfx::Rect expected_snapped_bounds(
284 kWorkAreaBounds.x() + kWorkAreaBounds.width() / 2, 292 kWorkAreaBounds.x() + kWorkAreaBounds.width() / 2,
285 kWorkAreaBounds.y(), 293 kWorkAreaBounds.y(),
286 kWorkAreaBounds.width() / 2, 294 kWorkAreaBounds.width() / 2,
287 kWorkAreaBounds.height()); 295 kWorkAreaBounds.height());
288 EXPECT_EQ(expected_snapped_bounds.ToString(), 296 EXPECT_EQ(expected_snapped_bounds.ToString(),
289 window->GetBoundsInScreen().ToString()); 297 window->GetBoundsInScreen().ToString());
290 298
291 // The window should still be auto managed despite being right maximized. 299 // The window should still be auto managed despite being right maximized.
292 EXPECT_TRUE(window_state->window_position_managed()); 300 EXPECT_TRUE(window_state->window_position_managed());
293 } 301 }
294 302
295 // Test that the replacement of a State object works as expected. 303 // Test that the replacement of a State object works as expected.
296 TEST_F(WindowStateTest, SimpleStateSwap) { 304 TEST_P(WindowStateTest, SimpleStateSwap) {
297 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 305 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
298 WindowState* window_state = GetWindowState(window.get()); 306 WindowState* window_state = GetWindowState(window.get());
299 EXPECT_FALSE(window_state->IsMaximized()); 307 EXPECT_FALSE(window_state->IsMaximized());
300 window_state->SetStateObject(std::unique_ptr<WindowState::State>( 308 window_state->SetStateObject(std::unique_ptr<WindowState::State>(
301 new AlwaysMaximizeTestState(window_state->GetStateType()))); 309 new AlwaysMaximizeTestState(window_state->GetStateType())));
302 EXPECT_TRUE(window_state->IsMaximized()); 310 EXPECT_TRUE(window_state->IsMaximized());
303 } 311 }
304 312
305 // Test that the replacement of a state object, following a restore with the 313 // Test that the replacement of a state object, following a restore with the
306 // original one restores the window to its original state. 314 // original one restores the window to its original state.
307 TEST_F(WindowStateTest, StateSwapRestore) { 315 TEST_P(WindowStateTest, StateSwapRestore) {
308 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 316 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
309 WindowState* window_state = GetWindowState(window.get()); 317 WindowState* window_state = GetWindowState(window.get());
310 EXPECT_FALSE(window_state->IsMaximized()); 318 EXPECT_FALSE(window_state->IsMaximized());
311 std::unique_ptr<WindowState::State> old( 319 std::unique_ptr<WindowState::State> old(
312 window_state->SetStateObject(std::unique_ptr<WindowState::State>( 320 window_state->SetStateObject(std::unique_ptr<WindowState::State>(
313 new AlwaysMaximizeTestState(window_state->GetStateType())))); 321 new AlwaysMaximizeTestState(window_state->GetStateType()))));
314 EXPECT_TRUE(window_state->IsMaximized()); 322 EXPECT_TRUE(window_state->IsMaximized());
315 window_state->SetStateObject(std::move(old)); 323 window_state->SetStateObject(std::move(old));
316 EXPECT_FALSE(window_state->IsMaximized()); 324 EXPECT_FALSE(window_state->IsMaximized());
317 } 325 }
318 326
319 // Tests that a window that had same bounds as the work area shrinks after the 327 // Tests that a window that had same bounds as the work area shrinks after the
320 // window is maximized and then restored. 328 // window is maximized and then restored.
321 TEST_F(WindowStateTest, RestoredWindowBoundsShrink) { 329 TEST_P(WindowStateTest, RestoredWindowBoundsShrink) {
330 if (!SupportsHostWindowResize())
331 return;
332
333 UpdateDisplay("0+0-600x900");
322 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 334 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
323 WindowState* window_state = GetWindowState(window.get()); 335 WindowState* window_state = GetWindowState(window.get());
324 EXPECT_FALSE(window_state->IsMaximized()); 336 EXPECT_FALSE(window_state->IsMaximized());
325 gfx::Rect work_area = 337 gfx::Rect work_area =
326 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); 338 display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
327 339
328 window->SetBounds(work_area); 340 window->SetBounds(work_area);
329 window_state->Maximize(); 341 window_state->Maximize();
330 EXPECT_TRUE(window_state->IsMaximized()); 342 EXPECT_TRUE(window_state->IsMaximized());
331 EXPECT_EQ(work_area.ToString(), window->bounds().ToString()); 343 EXPECT_EQ(work_area.ToString(), window->bounds().ToString());
332 344
333 window_state->Restore(); 345 window_state->Restore();
334 EXPECT_FALSE(window_state->IsMaximized()); 346 EXPECT_FALSE(window_state->IsMaximized());
335 EXPECT_NE(work_area.ToString(), window->bounds().ToString()); 347 EXPECT_NE(work_area.ToString(), window->bounds().ToString());
336 EXPECT_TRUE(work_area.Contains(window->bounds())); 348 EXPECT_TRUE(work_area.Contains(window->bounds()));
337 } 349 }
338 350
339 TEST_F(WindowStateTest, DoNotResizeMaximizedWindowInFullscreen) { 351 TEST_P(WindowStateTest, DoNotResizeMaximizedWindowInFullscreen) {
340 if (!SupportsHostWindowResize()) 352 if (!SupportsHostWindowResize())
341 return; 353 return;
354 const int height_offset = GetMdMaximizedWindowHeightOffset();
342 355
343 std::unique_ptr<aura::Window> maximized(CreateTestWindowInShellWithId(0)); 356 std::unique_ptr<aura::Window> maximized(CreateTestWindowInShellWithId(0));
344 std::unique_ptr<aura::Window> fullscreen(CreateTestWindowInShellWithId(1)); 357 std::unique_ptr<aura::Window> fullscreen(CreateTestWindowInShellWithId(1));
345 WindowState* maximized_state = GetWindowState(maximized.get()); 358 WindowState* maximized_state = GetWindowState(maximized.get());
346 maximized_state->Maximize(); 359 maximized_state->Maximize();
347 ASSERT_TRUE(maximized_state->IsMaximized()); 360 ASSERT_TRUE(maximized_state->IsMaximized());
348 EXPECT_EQ("0,0 800x553", maximized->GetBoundsInScreen().ToString()); 361 EXPECT_EQ(gfx::Rect(0, 0, 800, 553 + height_offset).ToString(),
362 maximized->GetBoundsInScreen().ToString());
349 363
350 // Entering fullscreen mode will not update the maximized window's size 364 // Entering fullscreen mode will not update the maximized window's size
351 // under fullscreen. 365 // under fullscreen.
352 WMEvent fullscreen_event(WM_EVENT_FULLSCREEN); 366 WMEvent fullscreen_event(WM_EVENT_FULLSCREEN);
353 WindowState* fullscreen_state = GetWindowState(fullscreen.get()); 367 WindowState* fullscreen_state = GetWindowState(fullscreen.get());
354 fullscreen_state->OnWMEvent(&fullscreen_event); 368 fullscreen_state->OnWMEvent(&fullscreen_event);
355 ASSERT_TRUE(fullscreen_state->IsFullscreen()); 369 ASSERT_TRUE(fullscreen_state->IsFullscreen());
356 ASSERT_TRUE(maximized_state->IsMaximized()); 370 ASSERT_TRUE(maximized_state->IsMaximized());
357 EXPECT_EQ("0,0 800x553", maximized->GetBoundsInScreen().ToString()); 371 EXPECT_EQ(gfx::Rect(0, 0, 800, 553 + height_offset).ToString(),
372 maximized->GetBoundsInScreen().ToString());
358 373
359 // Updating display size will update the maximum window size. 374 // Updating display size will update the maximum window size.
360 UpdateDisplay("900x700"); 375 UpdateDisplay("900x700");
361 EXPECT_EQ("0,0 900x700", maximized->GetBoundsInScreen().ToString()); 376 EXPECT_EQ("0,0 900x700", maximized->GetBoundsInScreen().ToString());
362 fullscreen.reset(); 377 fullscreen.reset();
363 378
364 // Exitting fullscreen will update the maximized widnow to the work area. 379 // Exiting fullscreen will update the maximized window to the work area.
365 EXPECT_EQ("0,0 900x653", maximized->GetBoundsInScreen().ToString()); 380 EXPECT_EQ(gfx::Rect(0, 0, 900, 653 + height_offset).ToString(),
381 maximized->GetBoundsInScreen().ToString());
366 } 382 }
367 383
368 // TODO(skuhne): Add more unit test to verify the correctness for the restore 384 // TODO(skuhne): Add more unit test to verify the correctness for the restore
369 // operation. 385 // operation.
370 386
371 } // namespace wm 387 } // namespace wm
372 } // namespace ash 388 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_positioner_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698