| 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/common/wm/window_state.h" | 7 #include "ash/common/wm/window_state.h" |
| 8 #include "ash/common/wm/wm_event.h" |
| 8 #include "ash/common/wm/workspace_controller.h" | 9 #include "ash/common/wm/workspace_controller.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 12 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/wm/resize_shadow.h" | 14 #include "ash/wm/resize_shadow.h" |
| 14 #include "ash/wm/resize_shadow_controller.h" | 15 #include "ash/wm/resize_shadow_controller.h" |
| 15 #include "ash/wm/window_state_aura.h" | 16 #include "ash/wm/window_state_aura.h" |
| 16 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
| 17 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.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/client/capture_client.h" | 22 #include "ui/aura/client/capture_client.h" |
| 22 #include "ui/aura/test/aura_test_base.h" | 23 #include "ui/aura/test/aura_test_base.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" |
| 27 #include "ui/display/manager/display_layout_builder.h" |
| 28 #include "ui/display/manager/display_manager.h" |
| 26 #include "ui/display/screen.h" | 29 #include "ui/display/screen.h" |
| 27 #include "ui/events/event.h" | 30 #include "ui/events/event.h" |
| 28 #include "ui/events/test/event_generator.h" | 31 #include "ui/events/test/event_generator.h" |
| 29 #include "ui/wm/core/window_util.h" | 32 #include "ui/wm/core/window_util.h" |
| 30 #include "ui/wm/public/window_move_client.h" | 33 #include "ui/wm/public/window_move_client.h" |
| 31 | 34 |
| 32 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 33 // Windows headers define macros for these function names which screw with us. | 36 // Windows headers define macros for these function names which screw with us. |
| 34 #if defined(CreateWindow) | 37 #if defined(CreateWindow) |
| 35 #undef CreateWindow | 38 #undef CreateWindow |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 aura::client::WindowMoveClient* move_client = | 758 aura::client::WindowMoveClient* move_client = |
| 756 aura::client::GetWindowMoveClient(window->GetRootWindow()); | 759 aura::client::GetWindowMoveClient(window->GetRootWindow()); |
| 757 base::ThreadTaskRunnerHandle::Get()->PostTask( | 760 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 758 FROM_HERE, base::Bind(&CheckHasCaptureAndReleaseCapture, | 761 FROM_HERE, base::Bind(&CheckHasCaptureAndReleaseCapture, |
| 759 base::Unretained(window.get()))); | 762 base::Unretained(window.get()))); |
| 760 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, | 763 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, |
| 761 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), | 764 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), |
| 762 aura::client::WINDOW_MOVE_SOURCE_TOUCH)); | 765 aura::client::WINDOW_MOVE_SOURCE_TOUCH)); |
| 763 } | 766 } |
| 764 | 767 |
| 768 // Tests that dragging a snapped window to another display updates the window's |
| 769 // bounds correctly. |
| 770 TEST_F(ToplevelWindowEventHandlerTest, DragSnappedWindowToExternalDisplay) { |
| 771 if (!SupportsMultipleDisplays()) |
| 772 return; |
| 773 |
| 774 UpdateDisplay("940x550,940x550"); |
| 775 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 776 int64_t secondary_id = display_manager()->GetSecondaryDisplay().id(); |
| 777 display::DisplayLayoutBuilder builder(primary_id); |
| 778 builder.SetSecondaryPlacement(secondary_id, display::DisplayPlacement::TOP, |
| 779 0); |
| 780 display_manager()->SetLayoutForCurrentDisplays(builder.Build()); |
| 781 |
| 782 const gfx::Size initial_window_size(330, 230); |
| 783 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegateAndType( |
| 784 new TestWindowDelegate(HTCAPTION), ui::wm::WINDOW_TYPE_NORMAL, 0, |
| 785 gfx::Rect(initial_window_size))); |
| 786 |
| 787 // Snap the window to the right. |
| 788 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 789 ASSERT_TRUE(window_state->CanSnap()); |
| 790 const wm::WMEvent event(wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT); |
| 791 window_state->OnWMEvent(&event); |
| 792 ASSERT_TRUE(window_state->IsSnapped()); |
| 793 |
| 794 // Drag the window to the secondary display. |
| 795 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get()); |
| 796 generator.DragMouseTo(472, -462); |
| 797 |
| 798 // Expect the window is no longer snapped and its size was restored to the |
| 799 // initial size. |
| 800 EXPECT_FALSE(window_state->IsSnapped()); |
| 801 EXPECT_EQ(initial_window_size.ToString(), w1->bounds().size().ToString()); |
| 802 |
| 803 // The window is now fully contained in the secondary display. |
| 804 EXPECT_TRUE(display_manager()->GetSecondaryDisplay().bounds().Contains( |
| 805 w1->GetBoundsInScreen())); |
| 806 } |
| 807 |
| 765 // Showing the resize shadows when the mouse is over the window edges is tested | 808 // Showing the resize shadows when the mouse is over the window edges is tested |
| 766 // in resize_shadow_and_cursor_test.cc | 809 // in resize_shadow_and_cursor_test.cc |
| 767 | 810 |
| 768 } // namespace test | 811 } // namespace test |
| 769 } // namespace ash | 812 } // namespace ash |
| OLD | NEW |