| 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/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| 11 #include "ash/common/wm/wm_event.h" | 11 #include "ash/common/wm/wm_event.h" |
| 12 #include "ash/test/ash_md_test_base.h" | 12 #include "ash/test/ash_md_test_base.h" |
| 13 #include "ash/wm/window_state_aura.h" | 13 #include "ash/wm/window_state_aura.h" |
| 14 #include "ash/wm/window_util.h" |
| 14 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 15 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
| 15 #include "ui/aura/client/aura_constants.h" | 16 #include "ui/aura/client/aura_constants.h" |
| 16 #include "ui/aura/test/test_window_delegate.h" | 17 #include "ui/aura/test/test_window_delegate.h" |
| 17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 18 #include "ui/display/manager/display_manager.h" | 19 #include "ui/display/manager/display_manager.h" |
| 19 #include "ui/display/screen.h" | 20 #include "ui/display/screen.h" |
| 20 | 21 |
| 21 namespace ash { | 22 namespace ash { |
| 22 namespace wm { | 23 namespace wm { |
| 23 namespace { | 24 namespace { |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 // Updating display size will update the maximum window size. | 354 // Updating display size will update the maximum window size. |
| 354 UpdateDisplay("900x700"); | 355 UpdateDisplay("900x700"); |
| 355 EXPECT_EQ("0,0 900x700", maximized->GetBoundsInScreen().ToString()); | 356 EXPECT_EQ("0,0 900x700", maximized->GetBoundsInScreen().ToString()); |
| 356 fullscreen.reset(); | 357 fullscreen.reset(); |
| 357 | 358 |
| 358 // Exiting fullscreen will update the maximized window to the work area. | 359 // Exiting fullscreen will update the maximized window to the work area. |
| 359 EXPECT_EQ(gfx::Rect(0, 0, 900, 653 + height_offset).ToString(), | 360 EXPECT_EQ(gfx::Rect(0, 0, 900, 653 + height_offset).ToString(), |
| 360 maximized->GetBoundsInScreen().ToString()); | 361 maximized->GetBoundsInScreen().ToString()); |
| 361 } | 362 } |
| 362 | 363 |
| 364 TEST_P(WindowStateTest, TrustedPinned) { |
| 365 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
| 366 WindowState* window_state = GetWindowState(window.get()); |
| 367 EXPECT_FALSE(window_state->IsTrustedPinned()); |
| 368 wm::PinWindow(window.get(), true /* trusted */); |
| 369 EXPECT_TRUE(window_state->IsTrustedPinned()); |
| 370 |
| 371 gfx::Rect work_area = |
| 372 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 373 EXPECT_EQ(work_area.ToString(), window->bounds().ToString()); |
| 374 |
| 375 // Sending non-unpin/non-workspace related event should be ignored. |
| 376 { |
| 377 const WMEvent fullscreen_event(WM_EVENT_FULLSCREEN); |
| 378 window_state->OnWMEvent(&fullscreen_event); |
| 379 } |
| 380 EXPECT_TRUE(window_state->IsTrustedPinned()); |
| 381 |
| 382 // Update display triggers workspace event. |
| 383 UpdateDisplay("300x200"); |
| 384 EXPECT_EQ("0,0 300x200", window->GetBoundsInScreen().ToString()); |
| 385 |
| 386 // Unpin should work. |
| 387 window_state->Restore(); |
| 388 EXPECT_FALSE(window_state->IsTrustedPinned()); |
| 389 } |
| 390 |
| 363 TEST_P(WindowStateTest, AllowSetBoundsInMaximized) { | 391 TEST_P(WindowStateTest, AllowSetBoundsInMaximized) { |
| 364 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 392 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
| 365 WindowState* window_state = GetWindowState(window.get()); | 393 WindowState* window_state = GetWindowState(window.get()); |
| 366 EXPECT_FALSE(window_state->IsMaximized()); | 394 EXPECT_FALSE(window_state->IsMaximized()); |
| 367 gfx::Rect work_area = | 395 gfx::Rect work_area = |
| 368 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 396 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 369 gfx::Rect original_bounds(50, 50, 200, 200); | 397 gfx::Rect original_bounds(50, 50, 200, 200); |
| 370 window->SetBounds(original_bounds); | 398 window->SetBounds(original_bounds); |
| 371 ASSERT_EQ(original_bounds, window->bounds()); | 399 ASSERT_EQ(original_bounds, window->bounds()); |
| 372 | 400 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 391 EXPECT_EQ(work_area, window->bounds()); | 419 EXPECT_EQ(work_area, window->bounds()); |
| 392 window->SetBounds(new_bounds); | 420 window->SetBounds(new_bounds); |
| 393 EXPECT_EQ(work_area, window->bounds()); | 421 EXPECT_EQ(work_area, window->bounds()); |
| 394 } | 422 } |
| 395 | 423 |
| 396 // TODO(skuhne): Add more unit test to verify the correctness for the restore | 424 // TODO(skuhne): Add more unit test to verify the correctness for the restore |
| 397 // operation. | 425 // operation. |
| 398 | 426 |
| 399 } // namespace wm | 427 } // namespace wm |
| 400 } // namespace ash | 428 } // namespace ash |
| OLD | NEW |