| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/workspace/workspace_layout_manager.h" | 5 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ash/common/wm/workspace/workspace_window_resizer.h" | 22 #include "ash/common/wm/workspace/workspace_window_resizer.h" |
| 23 #include "ash/common/wm_lookup.h" | 23 #include "ash/common/wm_lookup.h" |
| 24 #include "ash/common/wm_root_window_controller.h" | 24 #include "ash/common/wm_root_window_controller.h" |
| 25 #include "ash/common/wm_shell.h" | 25 #include "ash/common/wm_shell.h" |
| 26 #include "ash/public/cpp/shell_window_ids.h" | 26 #include "ash/public/cpp/shell_window_ids.h" |
| 27 #include "base/command_line.h" | 27 #include "base/command_line.h" |
| 28 #include "base/run_loop.h" | 28 #include "base/run_loop.h" |
| 29 #include "ui/aura/env.h" | 29 #include "ui/aura/env.h" |
| 30 #include "ui/base/ui_base_switches.h" | 30 #include "ui/base/ui_base_switches.h" |
| 31 #include "ui/base/ui_base_types.h" | 31 #include "ui/base/ui_base_types.h" |
| 32 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 32 #include "ui/display/display.h" | 33 #include "ui/display/display.h" |
| 33 #include "ui/display/screen.h" | 34 #include "ui/display/screen.h" |
| 34 #include "ui/gfx/geometry/insets.h" | 35 #include "ui/gfx/geometry/insets.h" |
| 35 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
| 36 #include "ui/views/widget/widget_delegate.h" | 37 #include "ui/views/widget/widget_delegate.h" |
| 37 | 38 |
| 38 namespace ash { | 39 namespace ash { |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 class MaximizeDelegateView : public views::WidgetDelegateView { | 42 class MaximizeDelegateView : public views::WidgetDelegateView { |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 window_state2->OnWMEvent(&toggle_fullscreen_event); | 533 window_state2->OnWMEvent(&toggle_fullscreen_event); |
| 533 EXPECT_EQ(5, observer.call_count()); | 534 EXPECT_EQ(5, observer.call_count()); |
| 534 EXPECT_TRUE(observer.is_fullscreen()); | 535 EXPECT_TRUE(observer.is_fullscreen()); |
| 535 | 536 |
| 536 // Closing the window should change the fullscreen state. | 537 // Closing the window should change the fullscreen state. |
| 537 window2_owner.reset(); | 538 window2_owner.reset(); |
| 538 EXPECT_EQ(6, observer.call_count()); | 539 EXPECT_EQ(6, observer.call_count()); |
| 539 EXPECT_FALSE(observer.is_fullscreen()); | 540 EXPECT_FALSE(observer.is_fullscreen()); |
| 540 } | 541 } |
| 541 | 542 |
| 543 // For crbug.com/673803, snapped window may not adjust snapped bounds on work |
| 544 // area changed properly if window's layer is doing animation. We should use |
| 545 // GetTargetBounds to check if snapped bounds need to be changed. |
| 546 TEST_F(WorkspaceLayoutManagerTest, |
| 547 SnappedWindowMayNotAdjustBoundsOnWorkAreaChanged) { |
| 548 UpdateDisplay("300x400"); |
| 549 std::unique_ptr<WindowOwner> window_owner( |
| 550 CreateTestWindow(gfx::Rect(10, 20, 100, 200))); |
| 551 WmWindow* window = window_owner->window(); |
| 552 wm::WindowState* window_state = window->GetWindowState(); |
| 553 gfx::Insets insets(0, 0, 50, 0); |
| 554 WmShell::Get()->SetDisplayWorkAreaInsets(window, insets); |
| 555 const wm::WMEvent snap_left(wm::WM_EVENT_SNAP_LEFT); |
| 556 window_state->OnWMEvent(&snap_left); |
| 557 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); |
| 558 const gfx::Rect kWorkAreaBounds = |
| 559 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 560 gfx::Rect expected_bounds = |
| 561 gfx::Rect(kWorkAreaBounds.x(), kWorkAreaBounds.y(), |
| 562 kWorkAreaBounds.width() / 2, kWorkAreaBounds.height()); |
| 563 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| 564 |
| 565 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 566 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 567 // The following two SetDisplayWorkAreaInsets calls simulate the case of |
| 568 // crbug.com/673803 that work area first becomes fullscreen and then returns |
| 569 // to the original state. |
| 570 WmShell::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets(0, 0, 0, 0)); |
| 571 ui::LayerAnimator* animator = window->GetLayer()->GetAnimator(); |
| 572 EXPECT_TRUE(animator->is_animating()); |
| 573 WmShell::Get()->SetDisplayWorkAreaInsets(window, insets); |
| 574 animator->StopAnimating(); |
| 575 EXPECT_FALSE(animator->is_animating()); |
| 576 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| 577 } |
| 578 |
| 542 // Following "Solo" tests were originally written for BaseLayoutManager. | 579 // Following "Solo" tests were originally written for BaseLayoutManager. |
| 543 using WorkspaceLayoutManagerSoloTest = AshTest; | 580 using WorkspaceLayoutManagerSoloTest = AshTest; |
| 544 | 581 |
| 545 // Tests normal->maximize->normal. | 582 // Tests normal->maximize->normal. |
| 546 TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) { | 583 TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) { |
| 547 gfx::Rect bounds(100, 100, 200, 200); | 584 gfx::Rect bounds(100, 100, 200, 200); |
| 548 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(bounds)); | 585 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(bounds)); |
| 549 WmWindow* window = window_owner->window(); | 586 WmWindow* window = window_owner->window(); |
| 550 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); | 587 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); |
| 551 // Maximized window fills the work area, not the whole display. | 588 // Maximized window fills the work area, not the whole display. |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 window->SetBounds(keyboard_bounds()); | 1249 window->SetBounds(keyboard_bounds()); |
| 1213 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); | 1250 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); |
| 1214 window->Activate(); | 1251 window->Activate(); |
| 1215 | 1252 |
| 1216 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1253 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
| 1217 ShowKeyboard(); | 1254 ShowKeyboard(); |
| 1218 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1255 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
| 1219 } | 1256 } |
| 1220 | 1257 |
| 1221 } // namespace ash | 1258 } // namespace ash |
| OLD | NEW |