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" |
11 #include "ash/wm/lock_state_controller.h" | 11 #include "ash/wm/lock_state_controller.h" |
12 #include "ash/wm/resize_shadow.h" | 12 #include "ash/wm/resize_shadow.h" |
13 #include "ash/wm/resize_shadow_controller.h" | 13 #include "ash/wm/resize_shadow_controller.h" |
14 #include "ash/wm/window_state.h" | 14 #include "ash/wm/window_state.h" |
15 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
16 #include "ash/wm/workspace_controller.h" | 16 #include "ash/wm/workspace_controller.h" |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 19 #include "base/message_loop/message_loop.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/aura/client/aura_constants.h" | 21 #include "ui/aura/client/aura_constants.h" |
21 #include "ui/aura/test/aura_test_base.h" | 22 #include "ui/aura/test/aura_test_base.h" |
22 #include "ui/aura/test/event_generator.h" | 23 #include "ui/aura/test/event_generator.h" |
23 #include "ui/aura/test/test_window_delegate.h" | 24 #include "ui/aura/test/test_window_delegate.h" |
24 #include "ui/aura/window_event_dispatcher.h" | 25 #include "ui/aura/window_event_dispatcher.h" |
25 #include "ui/base/hit_test.h" | 26 #include "ui/base/hit_test.h" |
26 #include "ui/events/event.h" | 27 #include "ui/events/event.h" |
27 #include "ui/gfx/screen.h" | 28 #include "ui/gfx/screen.h" |
28 #include "ui/wm/core/window_util.h" | 29 #include "ui/wm/core/window_util.h" |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 aura::client::WindowMoveClient* move_client = | 699 aura::client::WindowMoveClient* move_client = |
699 aura::client::GetWindowMoveClient(window2->GetRootWindow()); | 700 aura::client::GetWindowMoveClient(window2->GetRootWindow()); |
700 EXPECT_EQ(aura::client::MOVE_CANCELED, | 701 EXPECT_EQ(aura::client::MOVE_CANCELED, |
701 move_client->RunMoveLoop(window2.get(), gfx::Vector2d(), | 702 move_client->RunMoveLoop(window2.get(), gfx::Vector2d(), |
702 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); | 703 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); |
703 | 704 |
704 generator.ReleaseLeftButton(); | 705 generator.ReleaseLeftButton(); |
705 EXPECT_EQ("10,11 100x100", window1->bounds().ToString()); | 706 EXPECT_EQ("10,11 100x100", window1->bounds().ToString()); |
706 } | 707 } |
707 | 708 |
| 709 namespace { |
| 710 |
| 711 void SendMouseReleaseAndReleaseCapture(aura::test::EventGenerator* generator, |
| 712 aura::Window* window) { |
| 713 generator->ReleaseLeftButton(); |
| 714 window->ReleaseCapture(); |
| 715 } |
| 716 |
| 717 } // namespace |
| 718 |
| 719 // Test that a drag is successful even if ET_MOUSE_CAPTURE_CHANGED is sent |
| 720 // immediately after the mouse release. views::Widget has this behavior. |
| 721 TEST_F(ToplevelWindowEventHandlerTest, CaptureLossAfterMouseRelease) { |
| 722 scoped_ptr<aura::Window> window(CreateWindow(HTNOWHERE)); |
| 723 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 724 window.get()); |
| 725 generator.PressLeftButton(); |
| 726 window->SetCapture(); |
| 727 |
| 728 aura::client::WindowMoveClient* move_client = |
| 729 aura::client::GetWindowMoveClient(window->GetRootWindow()); |
| 730 base::MessageLoopForUI::current()->PostTask( |
| 731 FROM_HERE, |
| 732 base::Bind(&SendMouseReleaseAndReleaseCapture, |
| 733 base::Unretained(&generator), |
| 734 base::Unretained(window.get()))); |
| 735 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, |
| 736 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), |
| 737 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); |
| 738 } |
| 739 |
708 // Showing the resize shadows when the mouse is over the window edges is tested | 740 // Showing the resize shadows when the mouse is over the window edges is tested |
709 // in resize_shadow_and_cursor_test.cc | 741 // in resize_shadow_and_cursor_test.cc |
710 | 742 |
711 } // namespace test | 743 } // namespace test |
712 } // namespace ash | 744 } // namespace ash |
OLD | NEW |