| OLD | NEW |
| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 TEST_F(WindowStateTest, SnapWindowBasic) { | 55 TEST_F(WindowStateTest, SnapWindowBasic) { |
| 56 if (!SupportsMultipleDisplays()) | 56 if (!SupportsMultipleDisplays()) |
| 57 return; | 57 return; |
| 58 | 58 |
| 59 UpdateDisplay("0+0-500x400, 0+500-600x400"); | 59 UpdateDisplay("0+0-500x400, 0+500-600x400"); |
| 60 const gfx::Rect kPrimaryDisplayWorkAreaBounds = | 60 const gfx::Rect kPrimaryDisplayWorkAreaBounds = |
| 61 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 61 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 62 const gfx::Rect kSecondaryDisplayWorkAreaBounds = | 62 const gfx::Rect kSecondaryDisplayWorkAreaBounds = |
| 63 ScreenUtil::GetSecondaryDisplay().work_area(); | 63 ScreenUtil::GetSecondaryDisplay().work_area(); |
| 64 | 64 |
| 65 scoped_ptr<aura::Window> window( | 65 std::unique_ptr<aura::Window> window( |
| 66 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); | 66 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); |
| 67 WindowState* window_state = GetWindowState(window.get()); | 67 WindowState* window_state = GetWindowState(window.get()); |
| 68 const WMEvent snap_left(WM_EVENT_SNAP_LEFT); | 68 const WMEvent snap_left(WM_EVENT_SNAP_LEFT); |
| 69 window_state->OnWMEvent(&snap_left); | 69 window_state->OnWMEvent(&snap_left); |
| 70 gfx::Rect expected = gfx::Rect( | 70 gfx::Rect expected = gfx::Rect( |
| 71 kPrimaryDisplayWorkAreaBounds.x(), | 71 kPrimaryDisplayWorkAreaBounds.x(), |
| 72 kPrimaryDisplayWorkAreaBounds.y(), | 72 kPrimaryDisplayWorkAreaBounds.y(), |
| 73 kPrimaryDisplayWorkAreaBounds.width() / 2, | 73 kPrimaryDisplayWorkAreaBounds.width() / 2, |
| 74 kPrimaryDisplayWorkAreaBounds.height()); | 74 kPrimaryDisplayWorkAreaBounds.height()); |
| 75 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); | 75 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 101 // affect snapping. | 101 // affect snapping. |
| 102 TEST_F(WindowStateTest, SnapWindowMinimumSize) { | 102 TEST_F(WindowStateTest, SnapWindowMinimumSize) { |
| 103 if (!SupportsHostWindowResize()) | 103 if (!SupportsHostWindowResize()) |
| 104 return; | 104 return; |
| 105 | 105 |
| 106 UpdateDisplay("0+0-600x900"); | 106 UpdateDisplay("0+0-600x900"); |
| 107 const gfx::Rect kWorkAreaBounds = | 107 const gfx::Rect kWorkAreaBounds = |
| 108 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 108 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 109 | 109 |
| 110 aura::test::TestWindowDelegate delegate; | 110 aura::test::TestWindowDelegate delegate; |
| 111 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( | 111 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( |
| 112 &delegate, -1, gfx::Rect(0, 100, kWorkAreaBounds.width() - 1, 100))); | 112 &delegate, -1, gfx::Rect(0, 100, kWorkAreaBounds.width() - 1, 100))); |
| 113 | 113 |
| 114 // It should be possible to snap a window with a minimum size. | 114 // It should be possible to snap a window with a minimum size. |
| 115 delegate.set_minimum_size(gfx::Size(kWorkAreaBounds.width() - 1, 0)); | 115 delegate.set_minimum_size(gfx::Size(kWorkAreaBounds.width() - 1, 0)); |
| 116 WindowState* window_state = GetWindowState(window.get()); | 116 WindowState* window_state = GetWindowState(window.get()); |
| 117 EXPECT_TRUE(window_state->CanSnap()); | 117 EXPECT_TRUE(window_state->CanSnap()); |
| 118 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT); | 118 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT); |
| 119 window_state->OnWMEvent(&snap_right); | 119 window_state->OnWMEvent(&snap_right); |
| 120 gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x() + 1, | 120 gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x() + 1, |
| 121 kWorkAreaBounds.y(), | 121 kWorkAreaBounds.y(), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 138 TEST_F(WindowStateTest, TestRespectMinimumSize) { | 138 TEST_F(WindowStateTest, TestRespectMinimumSize) { |
| 139 if (!SupportsHostWindowResize()) | 139 if (!SupportsHostWindowResize()) |
| 140 return; | 140 return; |
| 141 | 141 |
| 142 UpdateDisplay("0+0-1024x768"); | 142 UpdateDisplay("0+0-1024x768"); |
| 143 | 143 |
| 144 aura::test::TestWindowDelegate delegate; | 144 aura::test::TestWindowDelegate delegate; |
| 145 const gfx::Size minimum_size(gfx::Size(500, 300)); | 145 const gfx::Size minimum_size(gfx::Size(500, 300)); |
| 146 delegate.set_minimum_size(minimum_size); | 146 delegate.set_minimum_size(minimum_size); |
| 147 | 147 |
| 148 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( | 148 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( |
| 149 &delegate, -1, gfx::Rect(0, 100, 100, 100))); | 149 &delegate, -1, gfx::Rect(0, 100, 100, 100))); |
| 150 | 150 |
| 151 // Check that the window has the correct minimum size. | 151 // Check that the window has the correct minimum size. |
| 152 EXPECT_EQ(minimum_size.ToString(), window->bounds().size().ToString()); | 152 EXPECT_EQ(minimum_size.ToString(), window->bounds().size().ToString()); |
| 153 | 153 |
| 154 // Set the size to something bigger - that should work. | 154 // Set the size to something bigger - that should work. |
| 155 gfx::Rect bigger_bounds(700, 500, 700, 500); | 155 gfx::Rect bigger_bounds(700, 500, 700, 500); |
| 156 window->SetBounds(bigger_bounds); | 156 window->SetBounds(bigger_bounds); |
| 157 EXPECT_EQ(bigger_bounds.ToString(), window->bounds().ToString()); | 157 EXPECT_EQ(bigger_bounds.ToString(), window->bounds().ToString()); |
| 158 | 158 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 173 const gfx::Size work_area_size = | 173 const gfx::Size work_area_size = |
| 174 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area().size(); | 174 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area().size(); |
| 175 const gfx::Size illegal_size(1280, 960); | 175 const gfx::Size illegal_size(1280, 960); |
| 176 const gfx::Rect illegal_bounds(gfx::Point(0, 0), illegal_size); | 176 const gfx::Rect illegal_bounds(gfx::Point(0, 0), illegal_size); |
| 177 | 177 |
| 178 aura::test::TestWindowDelegate delegate; | 178 aura::test::TestWindowDelegate delegate; |
| 179 const gfx::Size minimum_size(illegal_size); | 179 const gfx::Size minimum_size(illegal_size); |
| 180 delegate.set_minimum_size(minimum_size); | 180 delegate.set_minimum_size(minimum_size); |
| 181 | 181 |
| 182 // The creation should force the window to respect the screen size. | 182 // The creation should force the window to respect the screen size. |
| 183 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( | 183 std::unique_ptr<aura::Window> window( |
| 184 &delegate, -1, illegal_bounds)); | 184 CreateTestWindowInShellWithDelegate(&delegate, -1, illegal_bounds)); |
| 185 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString()); | 185 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString()); |
| 186 | 186 |
| 187 // Trying to set the size to something bigger then the screen size should be | 187 // Trying to set the size to something bigger then the screen size should be |
| 188 // ignored. | 188 // ignored. |
| 189 window->SetBounds(illegal_bounds); | 189 window->SetBounds(illegal_bounds); |
| 190 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString()); | 190 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString()); |
| 191 | 191 |
| 192 // Maximizing the window should not allow it to go bigger than that either. | 192 // Maximizing the window should not allow it to go bigger than that either. |
| 193 WindowState* window_state = GetWindowState(window.get()); | 193 WindowState* window_state = GetWindowState(window.get()); |
| 194 window_state->Maximize(); | 194 window_state->Maximize(); |
| 195 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString()); | 195 EXPECT_EQ(work_area_size.ToString(), window->bounds().size().ToString()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 // Test that setting the bounds of a snapped window keeps its snapped. | 198 // Test that setting the bounds of a snapped window keeps its snapped. |
| 199 TEST_F(WindowStateTest, SnapWindowSetBounds) { | 199 TEST_F(WindowStateTest, SnapWindowSetBounds) { |
| 200 if (!SupportsHostWindowResize()) | 200 if (!SupportsHostWindowResize()) |
| 201 return; | 201 return; |
| 202 | 202 |
| 203 UpdateDisplay("0+0-900x600"); | 203 UpdateDisplay("0+0-900x600"); |
| 204 const gfx::Rect kWorkAreaBounds = | 204 const gfx::Rect kWorkAreaBounds = |
| 205 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 205 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 206 | 206 |
| 207 scoped_ptr<aura::Window> window( | 207 std::unique_ptr<aura::Window> window( |
| 208 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); | 208 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); |
| 209 WindowState* window_state = GetWindowState(window.get()); | 209 WindowState* window_state = GetWindowState(window.get()); |
| 210 const WMEvent snap_left(WM_EVENT_SNAP_LEFT); | 210 const WMEvent snap_left(WM_EVENT_SNAP_LEFT); |
| 211 window_state->OnWMEvent(&snap_left); | 211 window_state->OnWMEvent(&snap_left); |
| 212 EXPECT_EQ(WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); | 212 EXPECT_EQ(WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); |
| 213 gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x(), | 213 gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x(), |
| 214 kWorkAreaBounds.y(), | 214 kWorkAreaBounds.y(), |
| 215 kWorkAreaBounds.width() / 2, | 215 kWorkAreaBounds.width() / 2, |
| 216 kWorkAreaBounds.height()); | 216 kWorkAreaBounds.height()); |
| 217 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); | 217 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); |
| 218 | 218 |
| 219 // Snapped windows can have any width. | 219 // Snapped windows can have any width. |
| 220 expected.set_width(500); | 220 expected.set_width(500); |
| 221 window->SetBounds(gfx::Rect(10, 10, 500, 300)); | 221 window->SetBounds(gfx::Rect(10, 10, 500, 300)); |
| 222 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); | 222 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); |
| 223 EXPECT_EQ(WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); | 223 EXPECT_EQ(WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); |
| 224 } | 224 } |
| 225 | 225 |
| 226 // Test that snapping left/right preserves the restore bounds. | 226 // Test that snapping left/right preserves the restore bounds. |
| 227 TEST_F(WindowStateTest, RestoreBounds) { | 227 TEST_F(WindowStateTest, RestoreBounds) { |
| 228 scoped_ptr<aura::Window> window( | 228 std::unique_ptr<aura::Window> window( |
| 229 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); | 229 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); |
| 230 WindowState* window_state = GetWindowState(window.get()); | 230 WindowState* window_state = GetWindowState(window.get()); |
| 231 | 231 |
| 232 EXPECT_TRUE(window_state->IsNormalStateType()); | 232 EXPECT_TRUE(window_state->IsNormalStateType()); |
| 233 | 233 |
| 234 // 1) Start with restored window with restore bounds set. | 234 // 1) Start with restored window with restore bounds set. |
| 235 gfx::Rect restore_bounds = window->GetBoundsInScreen(); | 235 gfx::Rect restore_bounds = window->GetBoundsInScreen(); |
| 236 restore_bounds.set_width(restore_bounds.width() + 1); | 236 restore_bounds.set_width(restore_bounds.width() + 1); |
| 237 window_state->SetRestoreBoundsInScreen(restore_bounds); | 237 window_state->SetRestoreBoundsInScreen(restore_bounds); |
| 238 const WMEvent snap_left(WM_EVENT_SNAP_LEFT); | 238 const WMEvent snap_left(WM_EVENT_SNAP_LEFT); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 259 EXPECT_EQ(restore_bounds.ToString(), | 259 EXPECT_EQ(restore_bounds.ToString(), |
| 260 window_state->GetRestoreBoundsInScreen().ToString()); | 260 window_state->GetRestoreBoundsInScreen().ToString()); |
| 261 | 261 |
| 262 window_state->Restore(); | 262 window_state->Restore(); |
| 263 EXPECT_EQ(restore_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 263 EXPECT_EQ(restore_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 // Test that maximizing an auto managed window, then snapping it puts the window | 266 // Test that maximizing an auto managed window, then snapping it puts the window |
| 267 // at the snapped bounds and not at the auto-managed (centered) bounds. | 267 // at the snapped bounds and not at the auto-managed (centered) bounds. |
| 268 TEST_F(WindowStateTest, AutoManaged) { | 268 TEST_F(WindowStateTest, AutoManaged) { |
| 269 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 269 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
| 270 WindowState* window_state = GetWindowState(window.get()); | 270 WindowState* window_state = GetWindowState(window.get()); |
| 271 window_state->set_window_position_managed(true); | 271 window_state->set_window_position_managed(true); |
| 272 window->Hide(); | 272 window->Hide(); |
| 273 window->SetBounds(gfx::Rect(100, 100, 100, 100)); | 273 window->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 274 window->Show(); | 274 window->Show(); |
| 275 | 275 |
| 276 window_state->Maximize(); | 276 window_state->Maximize(); |
| 277 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT); | 277 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT); |
| 278 window_state->OnWMEvent(&snap_right); | 278 window_state->OnWMEvent(&snap_right); |
| 279 | 279 |
| 280 const gfx::Rect kWorkAreaBounds = | 280 const gfx::Rect kWorkAreaBounds = |
| 281 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 281 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 282 gfx::Rect expected_snapped_bounds( | 282 gfx::Rect expected_snapped_bounds( |
| 283 kWorkAreaBounds.x() + kWorkAreaBounds.width() / 2, | 283 kWorkAreaBounds.x() + kWorkAreaBounds.width() / 2, |
| 284 kWorkAreaBounds.y(), | 284 kWorkAreaBounds.y(), |
| 285 kWorkAreaBounds.width() / 2, | 285 kWorkAreaBounds.width() / 2, |
| 286 kWorkAreaBounds.height()); | 286 kWorkAreaBounds.height()); |
| 287 EXPECT_EQ(expected_snapped_bounds.ToString(), | 287 EXPECT_EQ(expected_snapped_bounds.ToString(), |
| 288 window->GetBoundsInScreen().ToString()); | 288 window->GetBoundsInScreen().ToString()); |
| 289 | 289 |
| 290 // The window should still be auto managed despite being right maximized. | 290 // The window should still be auto managed despite being right maximized. |
| 291 EXPECT_TRUE(window_state->window_position_managed()); | 291 EXPECT_TRUE(window_state->window_position_managed()); |
| 292 } | 292 } |
| 293 | 293 |
| 294 // Test that the replacement of a State object works as expected. | 294 // Test that the replacement of a State object works as expected. |
| 295 TEST_F(WindowStateTest, SimpleStateSwap) { | 295 TEST_F(WindowStateTest, SimpleStateSwap) { |
| 296 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 296 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
| 297 WindowState* window_state = GetWindowState(window.get()); | 297 WindowState* window_state = GetWindowState(window.get()); |
| 298 EXPECT_FALSE(window_state->IsMaximized()); | 298 EXPECT_FALSE(window_state->IsMaximized()); |
| 299 window_state->SetStateObject( | 299 window_state->SetStateObject(std::unique_ptr<WindowState::State>( |
| 300 scoped_ptr<WindowState::State> (new AlwaysMaximizeTestState( | 300 new AlwaysMaximizeTestState(window_state->GetStateType()))); |
| 301 window_state->GetStateType()))); | |
| 302 EXPECT_TRUE(window_state->IsMaximized()); | 301 EXPECT_TRUE(window_state->IsMaximized()); |
| 303 } | 302 } |
| 304 | 303 |
| 305 // Test that the replacement of a state object, following a restore with the | 304 // Test that the replacement of a state object, following a restore with the |
| 306 // original one restores the window to its original state. | 305 // original one restores the window to its original state. |
| 307 TEST_F(WindowStateTest, StateSwapRestore) { | 306 TEST_F(WindowStateTest, StateSwapRestore) { |
| 308 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 307 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
| 309 WindowState* window_state = GetWindowState(window.get()); | 308 WindowState* window_state = GetWindowState(window.get()); |
| 310 EXPECT_FALSE(window_state->IsMaximized()); | 309 EXPECT_FALSE(window_state->IsMaximized()); |
| 311 scoped_ptr<WindowState::State> old( | 310 std::unique_ptr<WindowState::State> old( |
| 312 window_state->SetStateObject(scoped_ptr<WindowState::State>( | 311 window_state->SetStateObject(std::unique_ptr<WindowState::State>( |
| 313 new AlwaysMaximizeTestState(window_state->GetStateType())))); | 312 new AlwaysMaximizeTestState(window_state->GetStateType())))); |
| 314 EXPECT_TRUE(window_state->IsMaximized()); | 313 EXPECT_TRUE(window_state->IsMaximized()); |
| 315 window_state->SetStateObject(std::move(old)); | 314 window_state->SetStateObject(std::move(old)); |
| 316 EXPECT_FALSE(window_state->IsMaximized()); | 315 EXPECT_FALSE(window_state->IsMaximized()); |
| 317 } | 316 } |
| 318 | 317 |
| 319 // Tests that a window that had same bounds as the work area shrinks after the | 318 // Tests that a window that had same bounds as the work area shrinks after the |
| 320 // window is maximized and then restored. | 319 // window is maximized and then restored. |
| 321 TEST_F(WindowStateTest, RestoredWindowBoundsShrink) { | 320 TEST_F(WindowStateTest, RestoredWindowBoundsShrink) { |
| 322 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 321 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
| 323 WindowState* window_state = GetWindowState(window.get()); | 322 WindowState* window_state = GetWindowState(window.get()); |
| 324 EXPECT_FALSE(window_state->IsMaximized()); | 323 EXPECT_FALSE(window_state->IsMaximized()); |
| 325 gfx::Rect work_area = | 324 gfx::Rect work_area = |
| 326 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 325 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 327 | 326 |
| 328 window->SetBounds(work_area); | 327 window->SetBounds(work_area); |
| 329 window_state->Maximize(); | 328 window_state->Maximize(); |
| 330 EXPECT_TRUE(window_state->IsMaximized()); | 329 EXPECT_TRUE(window_state->IsMaximized()); |
| 331 EXPECT_EQ(work_area.ToString(), window->bounds().ToString()); | 330 EXPECT_EQ(work_area.ToString(), window->bounds().ToString()); |
| 332 | 331 |
| 333 window_state->Restore(); | 332 window_state->Restore(); |
| 334 EXPECT_FALSE(window_state->IsMaximized()); | 333 EXPECT_FALSE(window_state->IsMaximized()); |
| 335 EXPECT_NE(work_area.ToString(), window->bounds().ToString()); | 334 EXPECT_NE(work_area.ToString(), window->bounds().ToString()); |
| 336 EXPECT_TRUE(work_area.Contains(window->bounds())); | 335 EXPECT_TRUE(work_area.Contains(window->bounds())); |
| 337 } | 336 } |
| 338 | 337 |
| 339 TEST_F(WindowStateTest, DoNotResizeMaximizedWindowInFullscreen) { | 338 TEST_F(WindowStateTest, DoNotResizeMaximizedWindowInFullscreen) { |
| 340 if (!SupportsHostWindowResize()) | 339 if (!SupportsHostWindowResize()) |
| 341 return; | 340 return; |
| 342 | 341 |
| 343 scoped_ptr<aura::Window> maximized(CreateTestWindowInShellWithId(0)); | 342 std::unique_ptr<aura::Window> maximized(CreateTestWindowInShellWithId(0)); |
| 344 scoped_ptr<aura::Window> fullscreen(CreateTestWindowInShellWithId(1)); | 343 std::unique_ptr<aura::Window> fullscreen(CreateTestWindowInShellWithId(1)); |
| 345 WindowState* maximized_state = GetWindowState(maximized.get()); | 344 WindowState* maximized_state = GetWindowState(maximized.get()); |
| 346 maximized_state->Maximize(); | 345 maximized_state->Maximize(); |
| 347 ASSERT_TRUE(maximized_state->IsMaximized()); | 346 ASSERT_TRUE(maximized_state->IsMaximized()); |
| 348 EXPECT_EQ("0,0 800x553", maximized->GetBoundsInScreen().ToString()); | 347 EXPECT_EQ("0,0 800x553", maximized->GetBoundsInScreen().ToString()); |
| 349 | 348 |
| 350 // Entering fullscreen mode will not update the maximized window's size | 349 // Entering fullscreen mode will not update the maximized window's size |
| 351 // under fullscreen. | 350 // under fullscreen. |
| 352 WMEvent fullscreen_event(WM_EVENT_FULLSCREEN); | 351 WMEvent fullscreen_event(WM_EVENT_FULLSCREEN); |
| 353 WindowState* fullscreen_state = GetWindowState(fullscreen.get()); | 352 WindowState* fullscreen_state = GetWindowState(fullscreen.get()); |
| 354 fullscreen_state->OnWMEvent(&fullscreen_event); | 353 fullscreen_state->OnWMEvent(&fullscreen_event); |
| 355 ASSERT_TRUE(fullscreen_state->IsFullscreen()); | 354 ASSERT_TRUE(fullscreen_state->IsFullscreen()); |
| 356 ASSERT_TRUE(maximized_state->IsMaximized()); | 355 ASSERT_TRUE(maximized_state->IsMaximized()); |
| 357 EXPECT_EQ("0,0 800x553", maximized->GetBoundsInScreen().ToString()); | 356 EXPECT_EQ("0,0 800x553", maximized->GetBoundsInScreen().ToString()); |
| 358 | 357 |
| 359 // Updating display size will update the maximum window size. | 358 // Updating display size will update the maximum window size. |
| 360 UpdateDisplay("900x700"); | 359 UpdateDisplay("900x700"); |
| 361 EXPECT_EQ("0,0 900x700", maximized->GetBoundsInScreen().ToString()); | 360 EXPECT_EQ("0,0 900x700", maximized->GetBoundsInScreen().ToString()); |
| 362 fullscreen.reset(); | 361 fullscreen.reset(); |
| 363 | 362 |
| 364 // Exitting fullscreen will update the maximized widnow to the work area. | 363 // Exitting fullscreen will update the maximized widnow to the work area. |
| 365 EXPECT_EQ("0,0 900x653", maximized->GetBoundsInScreen().ToString()); | 364 EXPECT_EQ("0,0 900x653", maximized->GetBoundsInScreen().ToString()); |
| 366 } | 365 } |
| 367 | 366 |
| 368 // TODO(skuhne): Add more unit test to verify the correctness for the restore | 367 // TODO(skuhne): Add more unit test to verify the correctness for the restore |
| 369 // operation. | 368 // operation. |
| 370 | 369 |
| 371 } // namespace wm | 370 } // namespace wm |
| 372 } // namespace ash | 371 } // namespace ash |
| OLD | NEW |