Chromium Code Reviews| 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 TEST_F(WorkspaceLayoutManagerTest, SnappedWindowMayNotUpdateOnWorkAreaChanged) { | |
|
James Cook
2016/12/20 17:50:31
nit: Maybe call this test what you expect the good
Qiang(Joe) Xu
2016/12/21 02:37:55
done by adding a comment and adjust the title a li
| |
| 544 UpdateDisplay("300x400"); | |
| 545 std::unique_ptr<WindowOwner> window_owner( | |
| 546 CreateTestWindow(gfx::Rect(40, 40, 40, 40))); | |
|
James Cook
2016/12/20 17:50:31
tip: It doesn't matter here, but in tests, vary yo
Qiang(Joe) Xu
2016/12/21 02:37:55
Done.
| |
| 547 WmWindow* window = window_owner->window(); | |
| 548 wm::WindowState* window_state = window->GetWindowState(); | |
| 549 gfx::Insets insets(0, 0, 50, 0); | |
| 550 WmShell::Get()->SetDisplayWorkAreaInsets(window, insets); | |
| 551 const wm::WMEvent snap_left(wm::WM_EVENT_SNAP_LEFT); | |
| 552 window_state->OnWMEvent(&snap_left); | |
| 553 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); | |
| 554 const gfx::Rect kWorkAreaBounds = | |
| 555 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | |
| 556 gfx::Rect expected = | |
|
James Cook
2016/12/20 17:50:31
How about |expected_bounds| or |expected_window_bo
Qiang(Joe) Xu
2016/12/21 02:37:55
Done.
| |
| 557 gfx::Rect(kWorkAreaBounds.x(), kWorkAreaBounds.y(), | |
| 558 kWorkAreaBounds.width() / 2, kWorkAreaBounds.height()); | |
| 559 EXPECT_EQ(expected.ToString(), window->GetBounds().ToString()); | |
| 560 | |
| 561 ui::ScopedAnimationDurationScaleMode test_duration_mode( | |
| 562 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | |
| 563 // The following two SetDisplayWorkAreaInsets calls simulate the case of | |
| 564 // crbug.com/673803 that work area first becomes fullscreen and then return to | |
|
James Cook
2016/12/20 17:50:31
nit: return -> returns
Qiang(Joe) Xu
2016/12/21 02:37:55
Done.
| |
| 565 // the original state. | |
| 566 WmShell::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets(0, 0, 0, 0)); | |
| 567 ui::LayerAnimator* animator = window->GetLayer()->GetAnimator(); | |
| 568 EXPECT_TRUE(animator->is_animating()); | |
| 569 WmShell::Get()->SetDisplayWorkAreaInsets(window, insets); | |
| 570 animator->StopAnimating(); | |
| 571 EXPECT_FALSE(animator->is_animating()); | |
| 572 EXPECT_EQ(expected.ToString(), window->GetBounds().ToString()); | |
| 573 } | |
| 574 | |
| 542 // Following "Solo" tests were originally written for BaseLayoutManager. | 575 // Following "Solo" tests were originally written for BaseLayoutManager. |
| 543 using WorkspaceLayoutManagerSoloTest = AshTest; | 576 using WorkspaceLayoutManagerSoloTest = AshTest; |
| 544 | 577 |
| 545 // Tests normal->maximize->normal. | 578 // Tests normal->maximize->normal. |
| 546 TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) { | 579 TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) { |
| 547 gfx::Rect bounds(100, 100, 200, 200); | 580 gfx::Rect bounds(100, 100, 200, 200); |
| 548 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(bounds)); | 581 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(bounds)); |
| 549 WmWindow* window = window_owner->window(); | 582 WmWindow* window = window_owner->window(); |
| 550 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); | 583 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); |
| 551 // Maximized window fills the work area, not the whole display. | 584 // 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()); | 1245 window->SetBounds(keyboard_bounds()); |
| 1213 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); | 1246 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); |
| 1214 window->Activate(); | 1247 window->Activate(); |
| 1215 | 1248 |
| 1216 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1249 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
| 1217 ShowKeyboard(); | 1250 ShowKeyboard(); |
| 1218 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1251 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
| 1219 } | 1252 } |
| 1220 | 1253 |
| 1221 } // namespace ash | 1254 } // namespace ash |
| OLD | NEW |