Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1201)

Side by Side Diff: ash/wm/toplevel_window_event_handler_unittest.cc

Issue 2538293002: Fix dragging snapped window to another display landing the window in the wrong bounds (Closed)
Patch Set: I just needed to rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/wm/workspace/workspace_window_resizer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "services/ui/public/interfaces/window_manager_constants.mojom.h" 20 #include "services/ui/public/interfaces/window_manager_constants.mojom.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/aura/client/aura_constants.h" 22 #include "ui/aura/client/aura_constants.h"
22 #include "ui/aura/client/capture_client.h" 23 #include "ui/aura/client/capture_client.h"
23 #include "ui/aura/test/aura_test_base.h" 24 #include "ui/aura/test/aura_test_base.h"
24 #include "ui/aura/test/test_window_delegate.h" 25 #include "ui/aura/test/test_window_delegate.h"
25 #include "ui/aura/window_event_dispatcher.h" 26 #include "ui/aura/window_event_dispatcher.h"
26 #include "ui/base/hit_test.h" 27 #include "ui/base/hit_test.h"
28 #include "ui/display/display_layout_builder.h"
29 #include "ui/display/manager/display_manager.h"
27 #include "ui/display/screen.h" 30 #include "ui/display/screen.h"
28 #include "ui/events/event.h" 31 #include "ui/events/event.h"
29 #include "ui/events/test/event_generator.h" 32 #include "ui/events/test/event_generator.h"
30 #include "ui/wm/core/window_util.h" 33 #include "ui/wm/core/window_util.h"
31 #include "ui/wm/public/window_move_client.h" 34 #include "ui/wm/public/window_move_client.h"
32 35
33 #if defined(OS_WIN) 36 #if defined(OS_WIN)
34 // Windows headers define macros for these function names which screw with us. 37 // Windows headers define macros for these function names which screw with us.
35 #if defined(CreateWindow) 38 #if defined(CreateWindow)
36 #undef CreateWindow 39 #undef CreateWindow
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 aura::client::WindowMoveClient* move_client = 823 aura::client::WindowMoveClient* move_client =
821 aura::client::GetWindowMoveClient(window->GetRootWindow()); 824 aura::client::GetWindowMoveClient(window->GetRootWindow());
822 base::ThreadTaskRunnerHandle::Get()->PostTask( 825 base::ThreadTaskRunnerHandle::Get()->PostTask(
823 FROM_HERE, base::Bind(&CheckHasCaptureAndReleaseCapture, 826 FROM_HERE, base::Bind(&CheckHasCaptureAndReleaseCapture,
824 base::Unretained(window.get()))); 827 base::Unretained(window.get())));
825 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, 828 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
826 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), 829 move_client->RunMoveLoop(window.get(), gfx::Vector2d(),
827 aura::client::WINDOW_MOVE_SOURCE_TOUCH)); 830 aura::client::WINDOW_MOVE_SOURCE_TOUCH));
828 } 831 }
829 832
833 // Tests that dragging a snapped window to another display updates the window's
834 // bounds correctly.
835 TEST_F(ToplevelWindowEventHandlerTest, DragSnappedWindowToExternalDisplay) {
836 if (!SupportsMultipleDisplays())
837 return;
838
839 UpdateDisplay("940x550,940x550");
840 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
841 int64_t secondary_id = display_manager()->GetSecondaryDisplay().id();
842 display::DisplayLayoutBuilder builder(primary_id);
843 builder.SetSecondaryPlacement(secondary_id, display::DisplayPlacement::TOP,
844 0);
845 display_manager()->SetLayoutForCurrentDisplays(builder.Build());
846
847 const gfx::Size initial_window_size(330, 230);
848 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegateAndType(
849 new TestWindowDelegate(HTCAPTION), ui::wm::WINDOW_TYPE_NORMAL, 0,
850 gfx::Rect(initial_window_size)));
851
852 // Snap the window to the right.
853 wm::WindowState* window_state = wm::GetWindowState(w1.get());
854 ASSERT_TRUE(window_state->CanSnap());
855 const wm::WMEvent event(wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT);
856 window_state->OnWMEvent(&event);
857 ASSERT_TRUE(window_state->IsSnapped());
858
859 // Drag the window to the secondary display.
860 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get());
861 generator.DragMouseTo(472, -462);
862
863 // Expect the window is no longer snapped and its size was restored to the
864 // initial size.
865 EXPECT_FALSE(window_state->IsSnapped());
866 EXPECT_EQ(initial_window_size.ToString(), w1->bounds().size().ToString());
867
868 // The window is now fully contained in the secondary display.
869 EXPECT_TRUE(display_manager()->GetSecondaryDisplay().bounds().Contains(
870 w1->GetBoundsInScreen()));
871 }
872
830 // Showing the resize shadows when the mouse is over the window edges is tested 873 // Showing the resize shadows when the mouse is over the window edges is tested
831 // in resize_shadow_and_cursor_test.cc 874 // in resize_shadow_and_cursor_test.cc
832 875
833 } // namespace test 876 } // namespace test
834 } // namespace ash 877 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/workspace/workspace_window_resizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698