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/resize_shadow.h" | 11 #include "ash/wm/resize_shadow.h" |
12 #include "ash/wm/resize_shadow_controller.h" | 12 #include "ash/wm/resize_shadow_controller.h" |
13 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
15 #include "ash/wm/workspace_controller.h" | 15 #include "ash/wm/workspace_controller.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/message_loop/message_loop.h" | |
18 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
21 #include "ui/aura/test/aura_test_base.h" | 20 #include "ui/aura/test/aura_test_base.h" |
22 #include "ui/aura/test/test_window_delegate.h" | 21 #include "ui/aura/test/test_window_delegate.h" |
23 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
24 #include "ui/base/hit_test.h" | 23 #include "ui/base/hit_test.h" |
25 #include "ui/events/event.h" | 24 #include "ui/events/event.h" |
26 #include "ui/events/test/event_generator.h" | 25 #include "ui/events/test/event_generator.h" |
27 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 // immediately after the mouse release. views::Widget has this behavior. | 707 // immediately after the mouse release. views::Widget has this behavior. |
709 TEST_F(ToplevelWindowEventHandlerTest, CaptureLossAfterMouseRelease) { | 708 TEST_F(ToplevelWindowEventHandlerTest, CaptureLossAfterMouseRelease) { |
710 scoped_ptr<aura::Window> window(CreateWindow(HTNOWHERE)); | 709 scoped_ptr<aura::Window> window(CreateWindow(HTNOWHERE)); |
711 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 710 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
712 window.get()); | 711 window.get()); |
713 generator.PressLeftButton(); | 712 generator.PressLeftButton(); |
714 window->SetCapture(); | 713 window->SetCapture(); |
715 | 714 |
716 aura::client::WindowMoveClient* move_client = | 715 aura::client::WindowMoveClient* move_client = |
717 aura::client::GetWindowMoveClient(window->GetRootWindow()); | 716 aura::client::GetWindowMoveClient(window->GetRootWindow()); |
718 base::MessageLoopForUI::current()->PostTask( | 717 base::ThreadTaskRunnerHandle::Get()->PostTask( |
719 FROM_HERE, | 718 FROM_HERE, |
720 base::Bind(&SendMouseReleaseAndReleaseCapture, | 719 base::Bind(&SendMouseReleaseAndReleaseCapture, |
721 base::Unretained(&generator), | 720 base::Unretained(&generator), base::Unretained(window.get()))); |
722 base::Unretained(window.get()))); | |
723 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, | 721 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, |
724 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), | 722 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), |
725 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); | 723 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); |
726 } | 724 } |
727 | 725 |
728 namespace { | 726 namespace { |
729 | 727 |
730 // Checks that |window| has capture and releases capture. | 728 // Checks that |window| has capture and releases capture. |
731 void CheckHasCaptureAndReleaseCapture(aura::Window* window) { | 729 void CheckHasCaptureAndReleaseCapture(aura::Window* window) { |
732 ASSERT_TRUE(window->HasCapture()); | 730 ASSERT_TRUE(window->HasCapture()); |
(...skipping 16 matching lines...) Expand all Loading... |
749 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, | 747 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, |
750 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), | 748 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), |
751 aura::client::WINDOW_MOVE_SOURCE_TOUCH)); | 749 aura::client::WINDOW_MOVE_SOURCE_TOUCH)); |
752 } | 750 } |
753 | 751 |
754 // Showing the resize shadows when the mouse is over the window edges is tested | 752 // Showing the resize shadows when the mouse is over the window edges is tested |
755 // in resize_shadow_and_cursor_test.cc | 753 // in resize_shadow_and_cursor_test.cc |
756 | 754 |
757 } // namespace test | 755 } // namespace test |
758 } // namespace ash | 756 } // namespace ash |
OLD | NEW |