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/wm/workspace/workspace_event_handler.h" | 5 #include "ash/wm/workspace/workspace_event_handler.h" |
6 | 6 |
7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) { | 100 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) { |
101 // Double clicking the vertical resize edge of a window should maximize it | 101 // Double clicking the vertical resize edge of a window should maximize it |
102 // vertically. | 102 // vertically. |
103 gfx::Rect restored_bounds(10, 10, 50, 50); | 103 gfx::Rect restored_bounds(10, 10, 50, 50); |
104 aura::test::TestWindowDelegate delegate; | 104 aura::test::TestWindowDelegate delegate; |
105 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); | 105 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); |
106 | 106 |
107 wm::ActivateWindow(window.get()); | 107 wm::ActivateWindow(window.get()); |
108 | 108 |
109 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( | 109 gfx::Rect work_area = gfx::Screen::GetScreen() |
110 window.get()).work_area(); | 110 ->GetDisplayNearestWindow(window.get()) |
| 111 .work_area(); |
111 | 112 |
112 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 113 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
113 window.get()); | 114 window.get()); |
114 | 115 |
115 // Double-click the top resize edge. | 116 // Double-click the top resize edge. |
116 delegate.set_window_component(HTTOP); | 117 delegate.set_window_component(HTTOP); |
117 // On X a double click actually generates a drag between each press/release. | 118 // On X a double click actually generates a drag between each press/release. |
118 // Explicitly trigger this path since we had bugs in dealing with it | 119 // Explicitly trigger this path since we had bugs in dealing with it |
119 // correctly. | 120 // correctly. |
120 generator.PressLeftButton(); | 121 generator.PressLeftButton(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 generator2.DoubleClickLeftButton(); | 206 generator2.DoubleClickLeftButton(); |
206 EXPECT_EQ(restored_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 207 EXPECT_EQ(restored_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
207 } | 208 } |
208 | 209 |
209 // Tests the behavior when double clicking the border of a side snapped window. | 210 // Tests the behavior when double clicking the border of a side snapped window. |
210 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisWhenSideSnapped) { | 211 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisWhenSideSnapped) { |
211 gfx::Rect restored_bounds(10, 10, 50, 50); | 212 gfx::Rect restored_bounds(10, 10, 50, 50); |
212 aura::test::TestWindowDelegate delegate; | 213 aura::test::TestWindowDelegate delegate; |
213 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); | 214 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); |
214 | 215 |
215 gfx::Rect work_area_in_screen = Shell::GetScreen()->GetDisplayNearestWindow( | 216 gfx::Rect work_area_in_screen = gfx::Screen::GetScreen() |
216 window.get()).work_area(); | 217 ->GetDisplayNearestWindow(window.get()) |
| 218 .work_area(); |
217 | 219 |
218 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 220 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
219 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT); | 221 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT); |
220 window_state->OnWMEvent(&snap_event); | 222 window_state->OnWMEvent(&snap_event); |
221 | 223 |
222 gfx::Rect snapped_bounds_in_screen = window->GetBoundsInScreen(); | 224 gfx::Rect snapped_bounds_in_screen = window->GetBoundsInScreen(); |
223 EXPECT_EQ(work_area_in_screen.x(), snapped_bounds_in_screen.x()); | 225 EXPECT_EQ(work_area_in_screen.x(), snapped_bounds_in_screen.x()); |
224 EXPECT_EQ(work_area_in_screen.y(), snapped_bounds_in_screen.y()); | 226 EXPECT_EQ(work_area_in_screen.y(), snapped_bounds_in_screen.y()); |
225 EXPECT_GT(work_area_in_screen.width(), snapped_bounds_in_screen.width()); | 227 EXPECT_GT(work_area_in_screen.width(), snapped_bounds_in_screen.width()); |
226 EXPECT_EQ(work_area_in_screen.height(), snapped_bounds_in_screen.height()); | 228 EXPECT_EQ(work_area_in_screen.height(), snapped_bounds_in_screen.height()); |
(...skipping 19 matching lines...) Expand all Loading... |
246 } | 248 } |
247 | 249 |
248 TEST_F(WorkspaceEventHandlerTest, | 250 TEST_F(WorkspaceEventHandlerTest, |
249 DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained) { | 251 DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained) { |
250 gfx::Rect restored_bounds(10, 10, 50, 50); | 252 gfx::Rect restored_bounds(10, 10, 50, 50); |
251 aura::test::TestWindowDelegate delegate; | 253 aura::test::TestWindowDelegate delegate; |
252 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); | 254 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); |
253 | 255 |
254 wm::ActivateWindow(window.get()); | 256 wm::ActivateWindow(window.get()); |
255 | 257 |
256 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( | 258 gfx::Rect work_area = gfx::Screen::GetScreen() |
257 window.get()).work_area(); | 259 ->GetDisplayNearestWindow(window.get()) |
| 260 .work_area(); |
258 | 261 |
259 delegate.set_maximum_size(gfx::Size(0, 100)); | 262 delegate.set_maximum_size(gfx::Size(0, 100)); |
260 | 263 |
261 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 264 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
262 window.get()); | 265 window.get()); |
263 // Double-click the top resize edge. | 266 // Double-click the top resize edge. |
264 delegate.set_window_component(HTTOP); | 267 delegate.set_window_component(HTTOP); |
265 generator.DoubleClickLeftButton(); | 268 generator.DoubleClickLeftButton(); |
266 | 269 |
267 // The size of the window should be unchanged. | 270 // The size of the window should be unchanged. |
268 EXPECT_EQ(restored_bounds.y(), window->bounds().y()); | 271 EXPECT_EQ(restored_bounds.y(), window->bounds().y()); |
269 EXPECT_EQ(restored_bounds.height(), window->bounds().height()); | 272 EXPECT_EQ(restored_bounds.height(), window->bounds().height()); |
270 } | 273 } |
271 | 274 |
272 TEST_F(WorkspaceEventHandlerTest, | 275 TEST_F(WorkspaceEventHandlerTest, |
273 DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained) { | 276 DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained) { |
274 gfx::Rect restored_bounds(10, 10, 50, 50); | 277 gfx::Rect restored_bounds(10, 10, 50, 50); |
275 aura::test::TestWindowDelegate delegate; | 278 aura::test::TestWindowDelegate delegate; |
276 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); | 279 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); |
277 | 280 |
278 wm::ActivateWindow(window.get()); | 281 wm::ActivateWindow(window.get()); |
279 | 282 |
280 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( | 283 gfx::Rect work_area = gfx::Screen::GetScreen() |
281 window.get()).work_area(); | 284 ->GetDisplayNearestWindow(window.get()) |
| 285 .work_area(); |
282 | 286 |
283 delegate.set_maximum_size(gfx::Size(100, 0)); | 287 delegate.set_maximum_size(gfx::Size(100, 0)); |
284 | 288 |
285 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 289 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
286 window.get()); | 290 window.get()); |
287 // Double-click the top resize edge. | 291 // Double-click the top resize edge. |
288 delegate.set_window_component(HTRIGHT); | 292 delegate.set_window_component(HTRIGHT); |
289 generator.DoubleClickLeftButton(); | 293 generator.DoubleClickLeftButton(); |
290 | 294 |
291 // The size of the window should be unchanged. | 295 // The size of the window should be unchanged. |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 delegate.set_window_component(HTCAPTION); | 547 delegate.set_window_component(HTCAPTION); |
544 generator.PressRightButton(); | 548 generator.PressRightButton(); |
545 generator.ReleaseRightButton(); | 549 generator.ReleaseRightButton(); |
546 EXPECT_FALSE(window_state->IsMaximized()); | 550 EXPECT_FALSE(window_state->IsMaximized()); |
547 ClickButtonWithFlags(&generator, ui::EF_LEFT_MOUSE_BUTTON, | 551 ClickButtonWithFlags(&generator, ui::EF_LEFT_MOUSE_BUTTON, |
548 ui::EF_IS_DOUBLE_CLICK); | 552 ui::EF_IS_DOUBLE_CLICK); |
549 EXPECT_FALSE(window_state->IsMaximized()); | 553 EXPECT_FALSE(window_state->IsMaximized()); |
550 } | 554 } |
551 | 555 |
552 } // namespace ash | 556 } // namespace ash |
OLD | NEW |