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

Unified Diff: ash/display/extended_mouse_warp_controller_unittest.cc

Issue 1631023002: Fix moving the mouse between two displays after the secondary display becomes primary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Address comments Created 4 years, 11 months 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/display/extended_mouse_warp_controller_unittest.cc
diff --git a/ash/display/extended_mouse_warp_controller_unittest.cc b/ash/display/extended_mouse_warp_controller_unittest.cc
index 331ef88f34223fdc3473c3e4f02c4f7082be29d7..342d94978cd50db82cd1456df6e39aad3e2c62ec 100644
--- a/ash/display/extended_mouse_warp_controller_unittest.cc
+++ b/ash/display/extended_mouse_warp_controller_unittest.cc
@@ -49,14 +49,14 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnRight) {
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(359, 16, 1, 344),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(360, 0, 1, 360),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
EXPECT_EQ(gfx::Rect(360, 16, 1, 344),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(359, 0, 1, 360),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
// Move 2nd display downwards a bit.
layout.offset = 5;
@@ -66,14 +66,14 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnRight) {
// the indicator's x.
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(359, 16, 1, 344),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(360, 5, 1, 355),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
EXPECT_EQ(gfx::Rect(360, 21, 1, 339),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(359, 5, 1, 355),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
// Move it down further so that the shared edge is shorter than
// minimum hole size (160).
@@ -82,15 +82,15 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnRight) {
event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(359, 200, 1, 160),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(360, 200, 1, 160),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(360, 200, 1, 160),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(359, 200, 1, 160),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
// Now move 2nd display upwards
layout.offset = -5;
@@ -98,17 +98,17 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnRight) {
event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(359, 16, 1, 344),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(360, 0, 1, 360),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
// 16 px are reserved on 2nd display from top, so y must be
// (16 - 5) = 11
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(360, 11, 1, 349),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(359, 0, 1, 360),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->HideSharedEdgeIndicator();
}
@@ -126,30 +126,30 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnLeft) {
event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(0, 16, 1, 344),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(-1, 0, 1, 360),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(-1, 16, 1, 344),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(0, 0, 1, 360),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
layout.offset = 250;
display_manager->SetLayoutForCurrentDisplays(layout);
event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(0, 250, 1, 110),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(-1, 250, 1, 110),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(-1, 250, 1, 110),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(0, 250, 1, 110),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->HideSharedEdgeIndicator();
}
@@ -166,30 +166,30 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnTopBottom) {
event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(0, 0, 360, 1),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(0, -1, 360, 1),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(0, -1, 360, 1),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(0, 0, 360, 1),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
layout.offset = 250;
display_manager->SetLayoutForCurrentDisplays(layout);
event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(250, 0, 110, 1),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(250, -1, 110, 1),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(250, -1, 110, 1),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(250, 0, 110, 1),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
layout.position = DisplayLayout::BOTTOM;
layout.offset = 0;
@@ -197,15 +197,15 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnTopBottom) {
event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(0, 359, 360, 1),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(0, 360, 360, 1),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size());
EXPECT_EQ(gfx::Rect(0, 360, 360, 1),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
EXPECT_EQ(gfx::Rect(0, 359, 360, 1),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
event_filter()->HideSharedEdgeIndicator();
}
@@ -215,46 +215,54 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestThreeDisplays) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("360x360,700x700,1000x1000");
- aura::Window::Windows root_windows = Shell::GetAllRootWindows();
+ auto run_test = [this] {
+ aura::Window::Windows root_windows = Shell::GetAllRootWindows();
+
+ // Left most display
+ event_filter()->ShowSharedEdgeIndicator(root_windows[0]);
+ ASSERT_EQ(2U, mouse_warp_controller()->warp_regions_.size());
+ EXPECT_EQ(gfx::Rect(359, 16, 1, 344),
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
+ EXPECT_EQ(gfx::Rect(360, 0, 1, 360),
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
+ EXPECT_EQ(gfx::Rect(1060, 16, 1, 684),
+ mouse_warp_controller()->warp_regions_[1]->a_indicator_bounds());
+ EXPECT_EQ(gfx::Rect(1059, 0, 1, 700),
+ mouse_warp_controller()->warp_regions_[1]->b_indicator_bounds());
+
+ // Middle display
+ event_filter()->ShowSharedEdgeIndicator(root_windows[1]);
+ ASSERT_EQ(2U, mouse_warp_controller()->warp_regions_.size());
+ EXPECT_EQ(gfx::Rect(360, 16, 1, 344),
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
+ EXPECT_EQ(gfx::Rect(359, 0, 1, 360),
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
+ EXPECT_EQ(gfx::Rect(1059, 16, 1, 684),
+ mouse_warp_controller()->warp_regions_[1]->a_indicator_bounds());
+ EXPECT_EQ(gfx::Rect(1060, 0, 1, 700),
+ mouse_warp_controller()->warp_regions_[1]->b_indicator_bounds());
+
+ // Right most display
+ event_filter()->ShowSharedEdgeIndicator(root_windows[2]);
+ ASSERT_EQ(2U, mouse_warp_controller()->warp_regions_.size());
+ EXPECT_EQ(gfx::Rect(360, 16, 1, 344),
+ mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds());
+ EXPECT_EQ(gfx::Rect(359, 0, 1, 360),
+ mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds());
+ EXPECT_EQ(gfx::Rect(1060, 16, 1, 684),
+ mouse_warp_controller()->warp_regions_[1]->a_indicator_bounds());
+ EXPECT_EQ(gfx::Rect(1059, 0, 1, 700),
+ mouse_warp_controller()->warp_regions_[1]->b_indicator_bounds());
+
+ event_filter()->HideSharedEdgeIndicator();
+ };
- // Left most display
- event_filter()->ShowSharedEdgeIndicator(root_windows[0]);
- ASSERT_EQ(2U, mouse_warp_controller()->warp_regions_.size());
- EXPECT_EQ(gfx::Rect(359, 16, 1, 344),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
- EXPECT_EQ(gfx::Rect(360, 0, 1, 360),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
- EXPECT_EQ(gfx::Rect(1060, 16, 1, 684),
- mouse_warp_controller()->warp_regions_[1]->a_indicator_bounds);
- EXPECT_EQ(gfx::Rect(1059, 0, 1, 700),
- mouse_warp_controller()->warp_regions_[1]->b_indicator_bounds);
-
- // Middle display
- event_filter()->ShowSharedEdgeIndicator(root_windows[1]);
- ASSERT_EQ(2U, mouse_warp_controller()->warp_regions_.size());
- EXPECT_EQ(gfx::Rect(360, 16, 1, 344),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
- EXPECT_EQ(gfx::Rect(359, 0, 1, 360),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
- EXPECT_EQ(gfx::Rect(1059, 16, 1, 684),
- mouse_warp_controller()->warp_regions_[1]->a_indicator_bounds);
- EXPECT_EQ(gfx::Rect(1060, 0, 1, 700),
- mouse_warp_controller()->warp_regions_[1]->b_indicator_bounds);
-
- // Right most display
- event_filter()->ShowSharedEdgeIndicator(root_windows[2]);
- ASSERT_EQ(2U, mouse_warp_controller()->warp_regions_.size());
- EXPECT_EQ(gfx::Rect(360, 16, 1, 344),
- mouse_warp_controller()->warp_regions_[0]->a_indicator_bounds);
- EXPECT_EQ(gfx::Rect(359, 0, 1, 360),
- mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds);
- EXPECT_EQ(gfx::Rect(1060, 16, 1, 684),
- mouse_warp_controller()->warp_regions_[1]->a_indicator_bounds);
- EXPECT_EQ(gfx::Rect(1059, 0, 1, 700),
- mouse_warp_controller()->warp_regions_[1]->b_indicator_bounds);
+ UpdateDisplay("360x360,700x700,1000x1000");
+ run_test();
- event_filter()->HideSharedEdgeIndicator();
+ UpdateDisplay("360x360,700x700,1000x1000");
+ Shell::GetInstance()->window_tree_host_manager()->SwapPrimaryDisplayForTest();
+ run_test();
}
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698