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/screen_util.h" | 12 #include "ash/display/display_manager.h" |
13 #include "ash/test/ash_md_test_base.h" | 13 #include "ash/test/ash_md_test_base.h" |
14 #include "ash/wm/window_state_aura.h" | 14 #include "ash/wm/window_state_aura.h" |
15 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
16 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
18 #include "ui/display/screen.h" | 18 #include "ui/display/screen.h" |
19 | 19 |
20 namespace ash { | 20 namespace ash { |
21 namespace wm { | 21 namespace wm { |
22 namespace { | 22 namespace { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Test that a window gets properly snapped to the display's edges in a | 62 // Test that a window gets properly snapped to the display's edges in a |
63 // multi monitor environment. | 63 // multi monitor environment. |
64 TEST_P(WindowStateTest, SnapWindowBasic) { | 64 TEST_P(WindowStateTest, SnapWindowBasic) { |
65 if (!SupportsMultipleDisplays()) | 65 if (!SupportsMultipleDisplays()) |
66 return; | 66 return; |
67 | 67 |
68 UpdateDisplay("0+0-500x400, 0+500-600x400"); | 68 UpdateDisplay("0+0-500x400, 0+500-600x400"); |
69 const gfx::Rect kPrimaryDisplayWorkAreaBounds = | 69 const gfx::Rect kPrimaryDisplayWorkAreaBounds = |
70 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 70 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
71 const gfx::Rect kSecondaryDisplayWorkAreaBounds = | 71 const gfx::Rect kSecondaryDisplayWorkAreaBounds = |
72 ScreenUtil::GetSecondaryDisplay().work_area(); | 72 display_manager()->GetSecondaryDisplay().work_area(); |
73 | 73 |
74 std::unique_ptr<aura::Window> window( | 74 std::unique_ptr<aura::Window> window( |
75 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); | 75 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); |
76 WindowState* window_state = GetWindowState(window.get()); | 76 WindowState* window_state = GetWindowState(window.get()); |
77 const WMEvent snap_left(WM_EVENT_SNAP_LEFT); | 77 const WMEvent snap_left(WM_EVENT_SNAP_LEFT); |
78 window_state->OnWMEvent(&snap_left); | 78 window_state->OnWMEvent(&snap_left); |
79 gfx::Rect expected = gfx::Rect(kPrimaryDisplayWorkAreaBounds.x(), | 79 gfx::Rect expected = gfx::Rect(kPrimaryDisplayWorkAreaBounds.x(), |
80 kPrimaryDisplayWorkAreaBounds.y(), | 80 kPrimaryDisplayWorkAreaBounds.y(), |
81 kPrimaryDisplayWorkAreaBounds.width() / 2, | 81 kPrimaryDisplayWorkAreaBounds.width() / 2, |
82 kPrimaryDisplayWorkAreaBounds.height()); | 82 kPrimaryDisplayWorkAreaBounds.height()); |
83 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); | 83 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); |
84 | 84 |
85 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT); | 85 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT); |
86 window_state->OnWMEvent(&snap_right); | 86 window_state->OnWMEvent(&snap_right); |
87 expected.set_x(kPrimaryDisplayWorkAreaBounds.right() - expected.width()); | 87 expected.set_x(kPrimaryDisplayWorkAreaBounds.right() - expected.width()); |
88 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); | 88 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); |
89 | 89 |
90 // Move the window to the secondary display. | 90 // Move the window to the secondary display. |
91 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), | 91 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), |
92 ScreenUtil::GetSecondaryDisplay()); | 92 display_manager()->GetSecondaryDisplay()); |
93 | 93 |
94 window_state->OnWMEvent(&snap_right); | 94 window_state->OnWMEvent(&snap_right); |
95 expected = gfx::Rect(kSecondaryDisplayWorkAreaBounds.x() + | 95 expected = gfx::Rect(kSecondaryDisplayWorkAreaBounds.x() + |
96 kSecondaryDisplayWorkAreaBounds.width() / 2, | 96 kSecondaryDisplayWorkAreaBounds.width() / 2, |
97 kSecondaryDisplayWorkAreaBounds.y(), | 97 kSecondaryDisplayWorkAreaBounds.y(), |
98 kSecondaryDisplayWorkAreaBounds.width() / 2, | 98 kSecondaryDisplayWorkAreaBounds.width() / 2, |
99 kSecondaryDisplayWorkAreaBounds.height()); | 99 kSecondaryDisplayWorkAreaBounds.height()); |
100 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); | 100 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); |
101 | 101 |
102 window_state->OnWMEvent(&snap_left); | 102 window_state->OnWMEvent(&snap_left); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 EXPECT_EQ(work_area, window->bounds()); | 389 EXPECT_EQ(work_area, window->bounds()); |
390 window->SetBounds(new_bounds); | 390 window->SetBounds(new_bounds); |
391 EXPECT_EQ(work_area, window->bounds()); | 391 EXPECT_EQ(work_area, window->bounds()); |
392 } | 392 } |
393 | 393 |
394 // TODO(skuhne): Add more unit test to verify the correctness for the restore | 394 // TODO(skuhne): Add more unit test to verify the correctness for the restore |
395 // operation. | 395 // operation. |
396 | 396 |
397 } // namespace wm | 397 } // namespace wm |
398 } // namespace ash | 398 } // namespace ash |
OLD | NEW |