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/toplevel_window_event_handler.h" | 5 #include "ash/wm/toplevel_window_event_handler.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 298 |
299 // Simulate a large bottom-right to top-left drag. Window size should be | 299 // Simulate a large bottom-right to top-left drag. Window size should be |
300 // clamped to minimum and position should not change. | 300 // clamped to minimum and position should not change. |
301 DragFromCenterBy(w1.get(), -333, -444); | 301 DragFromCenterBy(w1.get(), -333, -444); |
302 EXPECT_EQ(position.ToString(), w1->bounds().origin().ToString()); | 302 EXPECT_EQ(position.ToString(), w1->bounds().origin().ToString()); |
303 EXPECT_EQ(gfx::Size(40, 40).ToString(), w1->bounds().size().ToString()); | 303 EXPECT_EQ(gfx::Size(40, 40).ToString(), w1->bounds().size().ToString()); |
304 } | 304 } |
305 | 305 |
306 TEST_F(ToplevelWindowEventHandlerTest, BottomRightWorkArea) { | 306 TEST_F(ToplevelWindowEventHandlerTest, BottomRightWorkArea) { |
307 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMRIGHT)); | 307 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMRIGHT)); |
308 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( | 308 gfx::Rect work_area = gfx::Screen::GetScreen() |
309 target.get()).work_area(); | 309 ->GetDisplayNearestWindow(target.get()) |
| 310 .work_area(); |
310 gfx::Point position = target->bounds().origin(); | 311 gfx::Point position = target->bounds().origin(); |
311 // Drag further than work_area bottom. | 312 // Drag further than work_area bottom. |
312 DragFromCenterBy(target.get(), 100, work_area.height()); | 313 DragFromCenterBy(target.get(), 100, work_area.height()); |
313 // Position should not have changed. | 314 // Position should not have changed. |
314 EXPECT_EQ(position.ToString(), target->bounds().origin().ToString()); | 315 EXPECT_EQ(position.ToString(), target->bounds().origin().ToString()); |
315 // Size should have increased by 100, work_area.height() - target->bounds.y() | 316 // Size should have increased by 100, work_area.height() - target->bounds.y() |
316 EXPECT_EQ( | 317 EXPECT_EQ( |
317 gfx::Size(200, work_area.height() - target->bounds().y()).ToString(), | 318 gfx::Size(200, work_area.height() - target->bounds().y()).ToString(), |
318 target->bounds().size().ToString()); | 319 target->bounds().size().ToString()); |
319 } | 320 } |
320 | 321 |
321 TEST_F(ToplevelWindowEventHandlerTest, BottomLeftWorkArea) { | 322 TEST_F(ToplevelWindowEventHandlerTest, BottomLeftWorkArea) { |
322 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMLEFT)); | 323 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMLEFT)); |
323 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( | 324 gfx::Rect work_area = gfx::Screen::GetScreen() |
324 target.get()).work_area(); | 325 ->GetDisplayNearestWindow(target.get()) |
| 326 .work_area(); |
325 gfx::Point position = target->bounds().origin(); | 327 gfx::Point position = target->bounds().origin(); |
326 // Drag further than work_area bottom. | 328 // Drag further than work_area bottom. |
327 DragFromCenterBy(target.get(), -30, work_area.height()); | 329 DragFromCenterBy(target.get(), -30, work_area.height()); |
328 // origin is now at 70, 100. | 330 // origin is now at 70, 100. |
329 EXPECT_EQ(position.x() - 30, target->bounds().x()); | 331 EXPECT_EQ(position.x() - 30, target->bounds().x()); |
330 EXPECT_EQ(position.y(), target->bounds().y()); | 332 EXPECT_EQ(position.y(), target->bounds().y()); |
331 // Size should have increased by 30, work_area.height() - target->bounds.y() | 333 // Size should have increased by 30, work_area.height() - target->bounds.y() |
332 EXPECT_EQ( | 334 EXPECT_EQ( |
333 gfx::Size(130, work_area.height() - target->bounds().y()).ToString(), | 335 gfx::Size(130, work_area.height() - target->bounds().y()).ToString(), |
334 target->bounds().size().ToString()); | 336 target->bounds().size().ToString()); |
335 } | 337 } |
336 | 338 |
337 TEST_F(ToplevelWindowEventHandlerTest, BottomWorkArea) { | 339 TEST_F(ToplevelWindowEventHandlerTest, BottomWorkArea) { |
338 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOM)); | 340 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOM)); |
339 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( | 341 gfx::Rect work_area = gfx::Screen::GetScreen() |
340 target.get()).work_area(); | 342 ->GetDisplayNearestWindow(target.get()) |
| 343 .work_area(); |
341 gfx::Point position = target->bounds().origin(); | 344 gfx::Point position = target->bounds().origin(); |
342 // Drag further than work_area bottom. | 345 // Drag further than work_area bottom. |
343 DragFromCenterBy(target.get(), 0, work_area.height()); | 346 DragFromCenterBy(target.get(), 0, work_area.height()); |
344 // Position should not have changed. | 347 // Position should not have changed. |
345 EXPECT_EQ(position.ToString(), target->bounds().origin().ToString()); | 348 EXPECT_EQ(position.ToString(), target->bounds().origin().ToString()); |
346 // Size should have increased by 0, work_area.height() - target->bounds.y() | 349 // Size should have increased by 0, work_area.height() - target->bounds.y() |
347 EXPECT_EQ( | 350 EXPECT_EQ( |
348 gfx::Size(100, work_area.height() - target->bounds().y()).ToString(), | 351 gfx::Size(100, work_area.height() - target->bounds().y()).ToString(), |
349 target->bounds().size().ToString()); | 352 target->bounds().size().ToString()); |
350 } | 353 } |
(...skipping 25 matching lines...) Expand all Loading... |
376 generator.MoveMouseTo(0, 5); | 379 generator.MoveMouseTo(0, 5); |
377 generator.DragMouseBy(0, -5); | 380 generator.DragMouseBy(0, -5); |
378 // The y location and height should not have changed. | 381 // The y location and height should not have changed. |
379 EXPECT_EQ(0, target->bounds().y()); | 382 EXPECT_EQ(0, target->bounds().y()); |
380 EXPECT_EQ(100, target->bounds().height()); | 383 EXPECT_EQ(100, target->bounds().height()); |
381 } | 384 } |
382 | 385 |
383 // Verifies we don't let windows go bigger than the display width. | 386 // Verifies we don't let windows go bigger than the display width. |
384 TEST_F(ToplevelWindowEventHandlerTest, DontGotWiderThanScreen) { | 387 TEST_F(ToplevelWindowEventHandlerTest, DontGotWiderThanScreen) { |
385 scoped_ptr<aura::Window> target(CreateWindow(HTRIGHT)); | 388 scoped_ptr<aura::Window> target(CreateWindow(HTRIGHT)); |
386 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( | 389 gfx::Rect work_area = |
387 target.get()).bounds(); | 390 gfx::Screen::GetScreen()->GetDisplayNearestWindow(target.get()).bounds(); |
388 DragFromCenterBy(target.get(), work_area.width() * 2, 0); | 391 DragFromCenterBy(target.get(), work_area.width() * 2, 0); |
389 // The y location and height should not have changed. | 392 // The y location and height should not have changed. |
390 EXPECT_EQ(work_area.width(), target->bounds().width()); | 393 EXPECT_EQ(work_area.width(), target->bounds().width()); |
391 } | 394 } |
392 | 395 |
393 // Verifies that touch-gestures drag the window correctly. | 396 // Verifies that touch-gestures drag the window correctly. |
394 TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) { | 397 TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) { |
395 scoped_ptr<aura::Window> target( | 398 scoped_ptr<aura::Window> target( |
396 CreateTestWindowInShellWithDelegate( | 399 CreateTestWindowInShellWithDelegate( |
397 new TestWindowDelegate(HTCAPTION), | 400 new TestWindowDelegate(HTCAPTION), |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, | 752 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, |
750 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), | 753 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), |
751 aura::client::WINDOW_MOVE_SOURCE_TOUCH)); | 754 aura::client::WINDOW_MOVE_SOURCE_TOUCH)); |
752 } | 755 } |
753 | 756 |
754 // Showing the resize shadows when the mouse is over the window edges is tested | 757 // Showing the resize shadows when the mouse is over the window edges is tested |
755 // in resize_shadow_and_cursor_test.cc | 758 // in resize_shadow_and_cursor_test.cc |
756 | 759 |
757 } // namespace test | 760 } // namespace test |
758 } // namespace ash | 761 } // namespace ash |
OLD | NEW |