blob: 6bc34a92de533aeb82cd271cea24d36dbeaf86d4 [file] [log] [blame]
oshima83e6f6f2015-04-24 00:30:281// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ash/display/extended_mouse_warp_controller.h"
6
oshima83e6f6f2015-04-24 00:30:287#include "ash/display/mouse_cursor_event_filter.h"
8#include "ash/shell.h"
9#include "ash/test/ash_test_base.h"
oshimaf84b0da722016-04-27 19:47:1910#include "ui/display/display.h"
kylechar731f85f92016-12-01 20:50:4611#include "ui/display/display_layout.h"
12#include "ui/display/display_layout_builder.h"
rjkroege72f8154f2016-10-29 00:49:0213#include "ui/display/manager/display_manager.h"
oshimaf84b0da722016-04-27 19:47:1914#include "ui/display/screen.h"
rjkroege72f8154f2016-10-29 00:49:0215#include "ui/display/test/display_manager_test_api.h"
oshima83e6f6f2015-04-24 00:30:2816#include "ui/events/test/event_generator.h"
oshima83e6f6f2015-04-24 00:30:2817
18namespace ash {
19
James Cook317781a2017-07-18 02:08:0620class ExtendedMouseWarpControllerTest : public AshTestBase {
oshima83e6f6f2015-04-24 00:30:2821 public:
Chris Watkinsc24daf62017-11-28 03:43:0922 ExtendedMouseWarpControllerTest() = default;
23 ~ExtendedMouseWarpControllerTest() override = default;
oshima83e6f6f2015-04-24 00:30:2824
25 protected:
26 MouseCursorEventFilter* event_filter() {
skycb4be5b2017-04-06 17:52:4527 return Shell::Get()->mouse_cursor_filter();
oshima83e6f6f2015-04-24 00:30:2828 }
29
30 ExtendedMouseWarpController* mouse_warp_controller() {
31 return static_cast<ExtendedMouseWarpController*>(
32 event_filter()->mouse_warp_controller_for_test());
33 }
34
oshima77570cb2016-03-24 21:33:2335 size_t GetWarpRegionsCount() {
36 return mouse_warp_controller()->warp_regions_.size();
37 }
38
39 const ExtendedMouseWarpController::WarpRegion* GetWarpRegion(size_t index) {
40 return mouse_warp_controller()->warp_regions_[index].get();
41 }
42
43 const gfx::Rect& GetIndicatorBounds(int64_t id) {
44 return GetWarpRegion(0)->GetIndicatorBoundsForTest(id);
45 }
46
oshima83e6f6f2015-04-24 00:30:2847 private:
48 DISALLOW_COPY_AND_ASSIGN(ExtendedMouseWarpControllerTest);
49};
50
51// Verifies if MouseCursorEventFilter's bounds calculation works correctly.
52TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnRight) {
oshima83e6f6f2015-04-24 00:30:2853 UpdateDisplay("360x360,700x700");
54 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
oshimaf84b0da722016-04-27 19:47:1955 int64_t display_0_id = display::Screen::GetScreen()
56 ->GetDisplayNearestWindow(root_windows[0])
57 .id();
58 int64_t display_1_id = display::Screen::GetScreen()
59 ->GetDisplayNearestWindow(root_windows[1])
60 .id();
oshima83e6f6f2015-04-24 00:30:2861
rjkroege72f8154f2016-10-29 00:49:0262 std::unique_ptr<display::DisplayLayout> layout(
63 display::test::CreateDisplayLayout(display_manager(),
64 display::DisplayPlacement::RIGHT, 0));
oshima77570cb2016-03-24 21:33:2365
rjkroege980ccfd2016-10-06 18:00:2466 display_manager()->SetLayoutForCurrentDisplays(layout->Copy());
oshima83e6f6f2015-04-24 00:30:2867 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
jdufaultfb0a42122016-01-21 21:40:4168
oshima77570cb2016-03-24 21:33:2369 ASSERT_EQ(1U, GetWarpRegionsCount());
70 EXPECT_EQ(gfx::Rect(359, 16, 1, 344), GetIndicatorBounds(display_0_id));
71 EXPECT_EQ(gfx::Rect(360, 0, 1, 360), GetIndicatorBounds(display_1_id));
72
oshima83e6f6f2015-04-24 00:30:2873 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
oshima77570cb2016-03-24 21:33:2374 EXPECT_EQ(gfx::Rect(359, 0, 1, 360), GetIndicatorBounds(display_0_id));
75 EXPECT_EQ(gfx::Rect(360, 16, 1, 344), GetIndicatorBounds(display_1_id));
oshima83e6f6f2015-04-24 00:30:2876
77 // Move 2nd display downwards a bit.
robliaodf372032016-03-23 00:42:3478 layout->placement_list[0].offset = 5;
rjkroege980ccfd2016-10-06 18:00:2479 display_manager()->SetLayoutForCurrentDisplays(layout->Copy());
oshima83e6f6f2015-04-24 00:30:2880 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
81 // This is same as before because the 2nd display's y is above
82 // the indicator's x.
oshima77570cb2016-03-24 21:33:2383 ASSERT_EQ(1U, GetWarpRegionsCount());
84 EXPECT_EQ(gfx::Rect(359, 16, 1, 344), GetIndicatorBounds(display_0_id));
85 EXPECT_EQ(gfx::Rect(360, 5, 1, 355), GetIndicatorBounds(display_1_id));
86
oshima83e6f6f2015-04-24 00:30:2887 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
oshima77570cb2016-03-24 21:33:2388 EXPECT_EQ(gfx::Rect(359, 5, 1, 355), GetIndicatorBounds(display_0_id));
89 EXPECT_EQ(gfx::Rect(360, 21, 1, 339), GetIndicatorBounds(display_1_id));
oshima83e6f6f2015-04-24 00:30:2890
91 // Move it down further so that the shared edge is shorter than
92 // minimum hole size (160).
robliaodf372032016-03-23 00:42:3493 layout->placement_list[0].offset = 200;
rjkroege980ccfd2016-10-06 18:00:2494 display_manager()->SetLayoutForCurrentDisplays(layout->Copy());
oshima83e6f6f2015-04-24 00:30:2895 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
oshima77570cb2016-03-24 21:33:2396 ASSERT_EQ(1U, GetWarpRegionsCount());
97 EXPECT_EQ(gfx::Rect(359, 200, 1, 160), GetIndicatorBounds(display_0_id));
98 EXPECT_EQ(gfx::Rect(360, 200, 1, 160), GetIndicatorBounds(display_1_id));
99
oshima83e6f6f2015-04-24 00:30:28100 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
oshima77570cb2016-03-24 21:33:23101 ASSERT_EQ(1U, GetWarpRegionsCount());
102 EXPECT_EQ(gfx::Rect(359, 200, 1, 160), GetIndicatorBounds(display_0_id));
103 EXPECT_EQ(gfx::Rect(360, 200, 1, 160), GetIndicatorBounds(display_1_id));
oshima83e6f6f2015-04-24 00:30:28104
105 // Now move 2nd display upwards
robliaodf372032016-03-23 00:42:34106 layout->placement_list[0].offset = -5;
rjkroege980ccfd2016-10-06 18:00:24107 display_manager()->SetLayoutForCurrentDisplays(layout->Copy());
oshima83e6f6f2015-04-24 00:30:28108 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
oshima77570cb2016-03-24 21:33:23109 ASSERT_EQ(1U, GetWarpRegionsCount());
110 EXPECT_EQ(gfx::Rect(359, 16, 1, 344), GetIndicatorBounds(display_0_id));
111 EXPECT_EQ(gfx::Rect(360, 0, 1, 360), GetIndicatorBounds(display_1_id));
oshima83e6f6f2015-04-24 00:30:28112 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
113 // 16 px are reserved on 2nd display from top, so y must be
114 // (16 - 5) = 11
oshima77570cb2016-03-24 21:33:23115 ASSERT_EQ(1U, GetWarpRegionsCount());
116 EXPECT_EQ(gfx::Rect(359, 0, 1, 360), GetIndicatorBounds(display_0_id));
117 EXPECT_EQ(gfx::Rect(360, 11, 1, 349), GetIndicatorBounds(display_1_id));
oshima83e6f6f2015-04-24 00:30:28118
119 event_filter()->HideSharedEdgeIndicator();
120}
121
122TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnLeft) {
oshima83e6f6f2015-04-24 00:30:28123 UpdateDisplay("360x360,700x700");
124 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
125
oshimaf84b0da722016-04-27 19:47:19126 int64_t display_0_id = display::Screen::GetScreen()
127 ->GetDisplayNearestWindow(root_windows[0])
128 .id();
129 int64_t display_1_id = display::Screen::GetScreen()
130 ->GetDisplayNearestWindow(root_windows[1])
131 .id();
oshima77570cb2016-03-24 21:33:23132
rjkroege72f8154f2016-10-29 00:49:02133 std::unique_ptr<display::DisplayLayout> layout(
134 display::test::CreateDisplayLayout(display_manager(),
135 display::DisplayPlacement::LEFT, 0));
rjkroege980ccfd2016-10-06 18:00:24136 display_manager()->SetLayoutForCurrentDisplays(layout->Copy());
oshima77570cb2016-03-24 21:33:23137
oshima83e6f6f2015-04-24 00:30:28138 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
oshima77570cb2016-03-24 21:33:23139 ASSERT_EQ(1U, GetWarpRegionsCount());
140 EXPECT_EQ(gfx::Rect(0, 16, 1, 344), GetIndicatorBounds(display_0_id));
141 EXPECT_EQ(gfx::Rect(-1, 0, 1, 360), GetIndicatorBounds(display_1_id));
142
oshima83e6f6f2015-04-24 00:30:28143 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
oshima77570cb2016-03-24 21:33:23144 ASSERT_EQ(1U, GetWarpRegionsCount());
145 EXPECT_EQ(gfx::Rect(0, 0, 1, 360), GetIndicatorBounds(display_0_id));
146 EXPECT_EQ(gfx::Rect(-1, 16, 1, 344), GetIndicatorBounds(display_1_id));
oshima83e6f6f2015-04-24 00:30:28147
robliaodf372032016-03-23 00:42:34148 layout->placement_list[0].offset = 250;
rjkroege980ccfd2016-10-06 18:00:24149 display_manager()->SetLayoutForCurrentDisplays(layout->Copy());
oshima83e6f6f2015-04-24 00:30:28150 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
oshima77570cb2016-03-24 21:33:23151 ASSERT_EQ(1U, GetWarpRegionsCount());
152 EXPECT_EQ(gfx::Rect(0, 250, 1, 110), GetIndicatorBounds(display_0_id));
153 EXPECT_EQ(gfx::Rect(-1, 250, 1, 110), GetIndicatorBounds(display_1_id));
154
oshima83e6f6f2015-04-24 00:30:28155 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
oshima77570cb2016-03-24 21:33:23156 ASSERT_EQ(1U, GetWarpRegionsCount());
157 EXPECT_EQ(gfx::Rect(0, 250, 1, 110), GetIndicatorBounds(display_0_id));
158 EXPECT_EQ(gfx::Rect(-1, 250, 1, 110), GetIndicatorBounds(display_1_id));
159
oshima83e6f6f2015-04-24 00:30:28160 event_filter()->HideSharedEdgeIndicator();
161}
162
163TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnTopBottom) {
oshima83e6f6f2015-04-24 00:30:28164 UpdateDisplay("360x360,700x700");
165 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
oshimaf84b0da722016-04-27 19:47:19166 int64_t display_0_id = display::Screen::GetScreen()
167 ->GetDisplayNearestWindow(root_windows[0])
168 .id();
169 int64_t display_1_id = display::Screen::GetScreen()
170 ->GetDisplayNearestWindow(root_windows[1])
171 .id();
oshima83e6f6f2015-04-24 00:30:28172
rjkroege72f8154f2016-10-29 00:49:02173 std::unique_ptr<display::DisplayLayout> layout(
174 display::test::CreateDisplayLayout(display_manager(),
175 display::DisplayPlacement::TOP, 0));
rjkroege980ccfd2016-10-06 18:00:24176 display_manager()->SetLayoutForCurrentDisplays(layout->Copy());
oshima83e6f6f2015-04-24 00:30:28177 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
oshima77570cb2016-03-24 21:33:23178 ASSERT_EQ(1U, GetWarpRegionsCount());
179 EXPECT_EQ(gfx::Rect(0, 0, 360, 1), GetIndicatorBounds(display_0_id));
180 EXPECT_EQ(gfx::Rect(0, -1, 360, 1), GetIndicatorBounds(display_1_id));
181
oshima83e6f6f2015-04-24 00:30:28182 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
oshima77570cb2016-03-24 21:33:23183 ASSERT_EQ(1U, GetWarpRegionsCount());
184 EXPECT_EQ(gfx::Rect(0, 0, 360, 1), GetIndicatorBounds(display_0_id));
185 EXPECT_EQ(gfx::Rect(0, -1, 360, 1), GetIndicatorBounds(display_1_id));
oshima83e6f6f2015-04-24 00:30:28186
robliaodf372032016-03-23 00:42:34187 layout->placement_list[0].offset = 250;
rjkroege980ccfd2016-10-06 18:00:24188 display_manager()->SetLayoutForCurrentDisplays(layout->Copy());
oshima83e6f6f2015-04-24 00:30:28189 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
oshima77570cb2016-03-24 21:33:23190 ASSERT_EQ(1U, GetWarpRegionsCount());
191 EXPECT_EQ(gfx::Rect(250, 0, 110, 1), GetIndicatorBounds(display_0_id));
192 EXPECT_EQ(gfx::Rect(250, -1, 110, 1), GetIndicatorBounds(display_1_id));
193
oshima83e6f6f2015-04-24 00:30:28194 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
oshima77570cb2016-03-24 21:33:23195 ASSERT_EQ(1U, GetWarpRegionsCount());
196 EXPECT_EQ(gfx::Rect(250, 0, 110, 1), GetIndicatorBounds(display_0_id));
197 EXPECT_EQ(gfx::Rect(250, -1, 110, 1), GetIndicatorBounds(display_1_id));
oshima83e6f6f2015-04-24 00:30:28198
robliaoc0dfd6b2016-04-07 21:33:56199 layout->placement_list[0].position = display::DisplayPlacement::BOTTOM;
robliaodf372032016-03-23 00:42:34200 layout->placement_list[0].offset = 0;
rjkroege980ccfd2016-10-06 18:00:24201 display_manager()->SetLayoutForCurrentDisplays(layout->Copy());
oshima83e6f6f2015-04-24 00:30:28202 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */);
oshima77570cb2016-03-24 21:33:23203 ASSERT_EQ(1U, GetWarpRegionsCount());
204 EXPECT_EQ(gfx::Rect(0, 359, 360, 1), GetIndicatorBounds(display_0_id));
205 EXPECT_EQ(gfx::Rect(0, 360, 360, 1), GetIndicatorBounds(display_1_id));
206
oshima83e6f6f2015-04-24 00:30:28207 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
oshima77570cb2016-03-24 21:33:23208 ASSERT_EQ(1U, GetWarpRegionsCount());
209 EXPECT_EQ(gfx::Rect(0, 359, 360, 1), GetIndicatorBounds(display_0_id));
210 EXPECT_EQ(gfx::Rect(0, 360, 360, 1), GetIndicatorBounds(display_1_id));
jdufaultfb0a42122016-01-21 21:40:41211
212 event_filter()->HideSharedEdgeIndicator();
213}
214
215// Verify indicators show up as expected with 3+ displays.
216TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestThreeDisplays) {
jdufaultfb0a42122016-01-21 21:40:41217 UpdateDisplay("360x360,700x700,1000x1000");
oshima77570cb2016-03-24 21:33:23218 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
oshimaf84b0da722016-04-27 19:47:19219 display::Screen* screen = display::Screen::GetScreen();
oshima77570cb2016-03-24 21:33:23220 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id();
221 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id();
222 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id();
jdufaultfb0a42122016-01-21 21:40:41223
oshima77570cb2016-03-24 21:33:23224 // Drag from left most display
225 event_filter()->ShowSharedEdgeIndicator(root_windows[0]);
226 ASSERT_EQ(2U, GetWarpRegionsCount());
227 const ExtendedMouseWarpController::WarpRegion* region_0 = GetWarpRegion(0);
228 const ExtendedMouseWarpController::WarpRegion* region_1 = GetWarpRegion(1);
229 EXPECT_EQ(gfx::Rect(359, 16, 1, 344),
230 region_1->GetIndicatorBoundsForTest(display_0_id));
231 EXPECT_EQ(gfx::Rect(360, 0, 1, 360),
232 region_1->GetIndicatorBoundsForTest(display_1_id));
233 EXPECT_EQ(gfx::Rect(1059, 0, 1, 700),
234 region_0->GetIndicatorBoundsForTest(display_1_id));
235 EXPECT_EQ(gfx::Rect(1060, 0, 1, 700),
236 region_0->GetIndicatorBoundsForTest(display_2_id));
237
238 // Drag from middle display
239 event_filter()->ShowSharedEdgeIndicator(root_windows[1]);
240 ASSERT_EQ(2U, mouse_warp_controller()->warp_regions_.size());
241 region_0 = GetWarpRegion(0);
242 region_1 = GetWarpRegion(1);
243 EXPECT_EQ(gfx::Rect(359, 0, 1, 360),
244 region_1->GetIndicatorBoundsForTest(display_0_id));
245 EXPECT_EQ(gfx::Rect(360, 16, 1, 344),
246 region_1->GetIndicatorBoundsForTest(display_1_id));
247 EXPECT_EQ(gfx::Rect(1059, 16, 1, 684),
248 region_0->GetIndicatorBoundsForTest(display_1_id));
249 EXPECT_EQ(gfx::Rect(1060, 0, 1, 700),
250 region_0->GetIndicatorBoundsForTest(display_2_id));
251
252 // Right most display
253 event_filter()->ShowSharedEdgeIndicator(root_windows[2]);
254 ASSERT_EQ(2U, mouse_warp_controller()->warp_regions_.size());
255 region_0 = GetWarpRegion(0);
256 region_1 = GetWarpRegion(1);
257 EXPECT_EQ(gfx::Rect(359, 0, 1, 360),
258 region_1->GetIndicatorBoundsForTest(display_0_id));
259 EXPECT_EQ(gfx::Rect(360, 0, 1, 360),
260 region_1->GetIndicatorBoundsForTest(display_1_id));
261 EXPECT_EQ(gfx::Rect(1059, 0, 1, 700),
262 region_0->GetIndicatorBoundsForTest(display_1_id));
263 EXPECT_EQ(gfx::Rect(1060, 16, 1, 684),
264 region_0->GetIndicatorBoundsForTest(display_2_id));
265 event_filter()->HideSharedEdgeIndicator();
266 // TODO(oshima): Add test cases primary swap.
267}
268
269TEST_F(ExtendedMouseWarpControllerTest,
270 IndicatorBoundsTestThreeDisplaysWithLayout) {
oshima77570cb2016-03-24 21:33:23271 UpdateDisplay("700x500,500x500,1000x1000");
272 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
oshimaf84b0da722016-04-27 19:47:19273 display::Screen* screen = display::Screen::GetScreen();
oshima77570cb2016-03-24 21:33:23274 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id();
275 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id();
276 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id();
277
278 // Layout so that all displays touches togter like this:
279 // +-----+---+
280 // | 0 | 1 |
281 // +-+---+--++
282 // | 2 |
283 // +------+
robliaoc0dfd6b2016-04-07 21:33:56284 display::DisplayLayoutBuilder builder(display_0_id);
oshima77570cb2016-03-24 21:33:23285 builder.AddDisplayPlacement(display_1_id, display_0_id,
robliaoc0dfd6b2016-04-07 21:33:56286 display::DisplayPlacement::RIGHT, 0);
oshima77570cb2016-03-24 21:33:23287 builder.AddDisplayPlacement(display_2_id, display_0_id,
robliaoc0dfd6b2016-04-07 21:33:56288 display::DisplayPlacement::BOTTOM, 100);
oshima77570cb2016-03-24 21:33:23289
rjkroege980ccfd2016-10-06 18:00:24290 display_manager()->SetLayoutForCurrentDisplays(builder.Build());
oshima77570cb2016-03-24 21:33:23291 ASSERT_EQ(3U, GetWarpRegionsCount());
292
293 // Drag from 0.
294 event_filter()->ShowSharedEdgeIndicator(root_windows[0]);
295 ASSERT_EQ(3U, GetWarpRegionsCount());
296 const ExtendedMouseWarpController::WarpRegion* region_0 = GetWarpRegion(0);
297 const ExtendedMouseWarpController::WarpRegion* region_1 = GetWarpRegion(1);
298 const ExtendedMouseWarpController::WarpRegion* region_2 = GetWarpRegion(2);
299 // between 2 and 0
300 EXPECT_EQ(gfx::Rect(100, 499, 600, 1),
301 region_0->GetIndicatorBoundsForTest(display_0_id));
302 EXPECT_EQ(gfx::Rect(100, 500, 600, 1),
303 region_0->GetIndicatorBoundsForTest(display_2_id));
304 // between 2 and 1
305 EXPECT_EQ(gfx::Rect(700, 499, 400, 1),
306 region_1->GetIndicatorBoundsForTest(display_1_id));
307 EXPECT_EQ(gfx::Rect(700, 500, 400, 1),
308 region_1->GetIndicatorBoundsForTest(display_2_id));
309 // between 1 and 0
310 EXPECT_EQ(gfx::Rect(699, 16, 1, 484),
311 region_2->GetIndicatorBoundsForTest(display_0_id));
312 EXPECT_EQ(gfx::Rect(700, 0, 1, 500),
313 region_2->GetIndicatorBoundsForTest(display_1_id));
314 event_filter()->HideSharedEdgeIndicator();
315}
316
317TEST_F(ExtendedMouseWarpControllerTest,
318 IndicatorBoundsTestThreeDisplaysWithLayout2) {
oshima77570cb2016-03-24 21:33:23319 UpdateDisplay("700x500,500x500,1000x1000");
320 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
oshimaf84b0da722016-04-27 19:47:19321 display::Screen* screen = display::Screen::GetScreen();
oshima77570cb2016-03-24 21:33:23322 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id();
323 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id();
324 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id();
325
326 // Layout so that 0 and 1 displays are disconnected.
327 // +-----+ +---+
328 // | 0 | |1 |
329 // +-+---+-+++
330 // | 2 |
331 // +------+
robliaoc0dfd6b2016-04-07 21:33:56332 display::DisplayLayoutBuilder builder(display_0_id);
oshima77570cb2016-03-24 21:33:23333 builder.AddDisplayPlacement(display_2_id, display_0_id,
robliaoc0dfd6b2016-04-07 21:33:56334 display::DisplayPlacement::BOTTOM, 100);
oshima77570cb2016-03-24 21:33:23335 builder.AddDisplayPlacement(display_1_id, display_2_id,
robliaoc0dfd6b2016-04-07 21:33:56336 display::DisplayPlacement::TOP, 800);
oshima77570cb2016-03-24 21:33:23337
rjkroege980ccfd2016-10-06 18:00:24338 display_manager()->SetLayoutForCurrentDisplays(builder.Build());
oshima77570cb2016-03-24 21:33:23339 ASSERT_EQ(2U, GetWarpRegionsCount());
340
341 // Drag from 0.
342 event_filter()->ShowSharedEdgeIndicator(root_windows[0]);
343 ASSERT_EQ(2U, GetWarpRegionsCount());
344 const ExtendedMouseWarpController::WarpRegion* region_0 = GetWarpRegion(0);
345 const ExtendedMouseWarpController::WarpRegion* region_1 = GetWarpRegion(1);
346 // between 2 and 0
347 EXPECT_EQ(gfx::Rect(100, 499, 600, 1),
348 region_0->GetIndicatorBoundsForTest(display_0_id));
349 EXPECT_EQ(gfx::Rect(100, 500, 600, 1),
350 region_0->GetIndicatorBoundsForTest(display_2_id));
351 // between 2 and 1
352 EXPECT_EQ(gfx::Rect(900, 499, 200, 1),
353 region_1->GetIndicatorBoundsForTest(display_1_id));
354 EXPECT_EQ(gfx::Rect(900, 500, 200, 1),
355 region_1->GetIndicatorBoundsForTest(display_2_id));
356 event_filter()->HideSharedEdgeIndicator();
oshima83e6f6f2015-04-24 00:30:28357}
358
359} // namespace ash