| 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/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/wm/window_state.h" | 9 #include "ash/common/wm/window_state.h" |
| 10 #include "ash/common/wm/window_state_util.h" | 10 #include "ash/common/wm/window_state_util.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 EXPECT_TRUE(window_state->IsMaximized()); | 313 EXPECT_TRUE(window_state->IsMaximized()); |
| 314 EXPECT_EQ(work_area.ToString(), window->bounds().ToString()); | 314 EXPECT_EQ(work_area.ToString(), window->bounds().ToString()); |
| 315 | 315 |
| 316 window_state->Restore(); | 316 window_state->Restore(); |
| 317 EXPECT_FALSE(window_state->IsMaximized()); | 317 EXPECT_FALSE(window_state->IsMaximized()); |
| 318 EXPECT_NE(work_area.ToString(), window->bounds().ToString()); | 318 EXPECT_NE(work_area.ToString(), window->bounds().ToString()); |
| 319 EXPECT_TRUE(work_area.Contains(window->bounds())); | 319 EXPECT_TRUE(work_area.Contains(window->bounds())); |
| 320 } | 320 } |
| 321 | 321 |
| 322 TEST_F(WindowStateTest, DoNotResizeMaximizedWindowInFullscreen) { | 322 TEST_F(WindowStateTest, DoNotResizeMaximizedWindowInFullscreen) { |
| 323 // TODO: investigate failure. http://crbug.com/698914. | |
| 324 if (WmShell::Get()->IsRunningInMash()) | |
| 325 return; | |
| 326 | |
| 327 std::unique_ptr<aura::Window> maximized(CreateTestWindowInShellWithId(0)); | 323 std::unique_ptr<aura::Window> maximized(CreateTestWindowInShellWithId(0)); |
| 328 std::unique_ptr<aura::Window> fullscreen(CreateTestWindowInShellWithId(1)); | 324 std::unique_ptr<aura::Window> fullscreen(CreateTestWindowInShellWithId(1)); |
| 329 WindowState* maximized_state = GetWindowState(maximized.get()); | 325 WindowState* maximized_state = GetWindowState(maximized.get()); |
| 330 maximized_state->Maximize(); | 326 maximized_state->Maximize(); |
| 331 ASSERT_TRUE(maximized_state->IsMaximized()); | 327 ASSERT_TRUE(maximized_state->IsMaximized()); |
| 332 EXPECT_EQ(gfx::Rect(0, 0, 800, 552).ToString(), | 328 EXPECT_EQ(gfx::Rect(0, 0, 800, 552).ToString(), |
| 333 maximized->GetBoundsInScreen().ToString()); | 329 maximized->GetBoundsInScreen().ToString()); |
| 334 | 330 |
| 335 // Entering fullscreen mode will not update the maximized window's size | 331 // Entering fullscreen mode will not update the maximized window's size |
| 336 // under fullscreen. | 332 // under fullscreen. |
| 337 WMEvent fullscreen_event(WM_EVENT_FULLSCREEN); | 333 WMEvent fullscreen_event(WM_EVENT_FULLSCREEN); |
| 338 WindowState* fullscreen_state = GetWindowState(fullscreen.get()); | 334 WindowState* fullscreen_state = GetWindowState(fullscreen.get()); |
| 339 fullscreen_state->OnWMEvent(&fullscreen_event); | 335 fullscreen_state->OnWMEvent(&fullscreen_event); |
| 340 ASSERT_TRUE(fullscreen_state->IsFullscreen()); | 336 ASSERT_TRUE(fullscreen_state->IsFullscreen()); |
| 341 ASSERT_TRUE(maximized_state->IsMaximized()); | 337 ASSERT_TRUE(maximized_state->IsMaximized()); |
| 342 EXPECT_EQ(gfx::Rect(0, 0, 800, 552).ToString(), | 338 EXPECT_EQ(gfx::Rect(0, 0, 800, 552).ToString(), |
| 343 maximized->GetBoundsInScreen().ToString()); | 339 maximized->GetBoundsInScreen().ToString()); |
| 344 | 340 |
| 345 // Updating display size will update the maximum window size. | 341 // Updating display size will update the maximum window size. |
| 346 UpdateDisplay("900x700"); | 342 UpdateDisplay("900x700"); |
| 347 EXPECT_EQ("0,0 900x700", maximized->GetBoundsInScreen().ToString()); | 343 EXPECT_EQ("0,0 900x700", maximized->GetBoundsInScreen().ToString()); |
| 348 fullscreen.reset(); | 344 fullscreen.reset(); |
| 349 | 345 |
| 350 // Exiting fullscreen will update the maximized window to the work area. | 346 // Exiting fullscreen will update the maximized window to the work area. |
| 351 EXPECT_EQ(gfx::Rect(0, 0, 900, 652).ToString(), | 347 EXPECT_EQ(gfx::Rect(0, 0, 900, 652).ToString(), |
| 352 maximized->GetBoundsInScreen().ToString()); | 348 maximized->GetBoundsInScreen().ToString()); |
| 353 } | 349 } |
| 354 | 350 |
| 355 TEST_F(WindowStateTest, TrustedPinned) { | 351 TEST_F(WindowStateTest, TrustedPinned) { |
| 356 // TODO: investigate failure. http://crbug.com/698914. | |
| 357 if (WmShell::Get()->IsRunningInMash()) | |
| 358 return; | |
| 359 | |
| 360 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 352 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
| 361 WindowState* window_state = GetWindowState(window.get()); | 353 WindowState* window_state = GetWindowState(window.get()); |
| 362 EXPECT_FALSE(window_state->IsTrustedPinned()); | 354 EXPECT_FALSE(window_state->IsTrustedPinned()); |
| 363 wm::PinWindow(window.get(), true /* trusted */); | 355 wm::PinWindow(window.get(), true /* trusted */); |
| 364 EXPECT_TRUE(window_state->IsTrustedPinned()); | 356 EXPECT_TRUE(window_state->IsTrustedPinned()); |
| 365 | 357 |
| 366 gfx::Rect work_area = | 358 gfx::Rect work_area = |
| 367 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 359 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 368 EXPECT_EQ(work_area.ToString(), window->bounds().ToString()); | 360 EXPECT_EQ(work_area.ToString(), window->bounds().ToString()); |
| 369 | 361 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 // return to the state before minimizing and fullscreen. | 456 // return to the state before minimizing and fullscreen. |
| 465 ash::wm::ToggleFullScreen(window_state, nullptr); | 457 ash::wm::ToggleFullScreen(window_state, nullptr); |
| 466 ASSERT_TRUE(window_state->IsMaximized()); | 458 ASSERT_TRUE(window_state->IsMaximized()); |
| 467 } | 459 } |
| 468 | 460 |
| 469 // TODO(skuhne): Add more unit test to verify the correctness for the restore | 461 // TODO(skuhne): Add more unit test to verify the correctness for the restore |
| 470 // operation. | 462 // operation. |
| 471 | 463 |
| 472 } // namespace wm | 464 } // namespace wm |
| 473 } // namespace ash | 465 } // namespace ash |
| OLD | NEW |