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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/toplevel_window_event_handler_unittest.cc
diff --git a/ash/wm/toplevel_window_event_handler_unittest.cc b/ash/wm/toplevel_window_event_handler_unittest.cc
index b7c26120d6ecc16f5d91f17c475087f30f1ee2a9..87951b6851ab2d3acbb6a5e0483034b44454b9bf 100644
--- a/ash/wm/toplevel_window_event_handler_unittest.cc
+++ b/ash/wm/toplevel_window_event_handler_unittest.cc
@@ -5,6 +5,7 @@
#include "ash/wm/toplevel_window_event_handler.h"
#include "ash/common/wm/window_state.h"
+#include "ash/common/wm/wm_event.h"
#include "ash/common/wm/workspace_controller.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/root_window_controller.h"
@@ -23,6 +24,8 @@
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/hit_test.h"
+#include "ui/display/manager/display_layout_builder.h"
+#include "ui/display/manager/display_manager.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/events/test/event_generator.h"
@@ -762,6 +765,46 @@ TEST_F(ToplevelWindowEventHandlerTest, GestureDragCaptureLoss) {
aura::client::WINDOW_MOVE_SOURCE_TOUCH));
}
+// Tests that dragging a snapped window to another display updates the window's
+// bounds correctly.
+TEST_F(ToplevelWindowEventHandlerTest, DragSnappedWindowToExternalDisplay) {
+ if (!SupportsMultipleDisplays())
+ return;
+
+ UpdateDisplay("940x550,940x550");
+ int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
+ int64_t secondary_id = display_manager()->GetSecondaryDisplay().id();
+ display::DisplayLayoutBuilder builder(primary_id);
+ builder.SetSecondaryPlacement(secondary_id, display::DisplayPlacement::TOP,
+ 0);
+ display_manager()->SetLayoutForCurrentDisplays(builder.Build());
+
+ const gfx::Size initial_window_size(330, 230);
+ std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegateAndType(
+ new TestWindowDelegate(HTCAPTION), ui::wm::WINDOW_TYPE_NORMAL, 0,
+ gfx::Rect(initial_window_size)));
+
+ // Snap the window to the right.
+ wm::WindowState* window_state = wm::GetWindowState(w1.get());
+ ASSERT_TRUE(window_state->CanSnap());
+ const wm::WMEvent event(wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT);
+ window_state->OnWMEvent(&event);
+ ASSERT_TRUE(window_state->IsSnapped());
+
+ // Drag the window to the secondary display.
+ ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get());
+ generator.DragMouseTo(472, -462);
+
+ // Expect the window is no longer snapped and its size was restored to the
+ // initial size.
+ EXPECT_FALSE(window_state->IsSnapped());
+ EXPECT_EQ(initial_window_size.ToString(), w1->bounds().size().ToString());
+
+ // The window is now fully contained in the secondary display.
+ EXPECT_TRUE(display_manager()->GetSecondaryDisplay().bounds().Contains(
+ w1->GetBoundsInScreen()));
+}
+
// Showing the resize shadows when the mouse is over the window edges is tested
// in resize_shadow_and_cursor_test.cc
« ash/common/wm/default_state.cc ('K') | « 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