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
3 // found in the LICENSE file.
5 #include "ash/wm/drag_window_resizer.h"
7 #include "ash/display/mouse_cursor_event_filter.h"
8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shell.h"
11 #include "ash/shell_window_ids.h"
12 #include "ash/test/ash_test_base.h"
13 #include "ash/test/cursor_manager_test_api.h"
14 #include "ash/wm/drag_window_controller.h"
15 #include "ash/wm/window_util.h"
16 #include "base/strings/stringprintf.h"
17 #include "ui/aura/client/aura_constants.h"
18 #include "ui/aura/root_window.h"
19 #include "ui/aura/test/test_window_delegate.h"
20 #include "ui/base/hit_test.h"
21 #include "ui/base/ui_base_types.h"
22 #include "ui/gfx/insets.h"
23 #include "ui/gfx/screen.h"
24 #include "ui/views/widget/widget.h"
30 const int kRootHeight
= 600;
34 class DragWindowResizerTest
: public test::AshTestBase
{
36 DragWindowResizerTest() {}
37 virtual ~DragWindowResizerTest() {}
39 virtual void SetUp() OVERRIDE
{
41 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight
));
43 aura::RootWindow
* root
= Shell::GetPrimaryRootWindow();
44 gfx::Rect
root_bounds(root
->bounds());
45 EXPECT_EQ(kRootHeight
, root_bounds
.height());
46 EXPECT_EQ(800, root_bounds
.width());
47 Shell::GetInstance()->SetDisplayWorkAreaInsets(root
, gfx::Insets());
48 window_
.reset(new aura::Window(&delegate_
));
49 window_
->SetType(aura::client::WINDOW_TYPE_NORMAL
);
50 window_
->Init(ui::LAYER_NOT_DRAWN
);
51 SetDefaultParentByPrimaryRootWindow(window_
.get());
54 always_on_top_window_
.reset(new aura::Window(&delegate2_
));
55 always_on_top_window_
->SetType(aura::client::WINDOW_TYPE_NORMAL
);
56 always_on_top_window_
->SetProperty(aura::client::kAlwaysOnTopKey
, true);
57 always_on_top_window_
->Init(ui::LAYER_NOT_DRAWN
);
58 SetDefaultParentByPrimaryRootWindow(always_on_top_window_
.get());
59 always_on_top_window_
->set_id(2);
61 system_modal_window_
.reset(new aura::Window(&delegate3_
));
62 system_modal_window_
->SetType(aura::client::WINDOW_TYPE_NORMAL
);
63 system_modal_window_
->SetProperty(aura::client::kModalKey
,
64 ui::MODAL_TYPE_SYSTEM
);
65 system_modal_window_
->Init(ui::LAYER_NOT_DRAWN
);
66 SetDefaultParentByPrimaryRootWindow(system_modal_window_
.get());
67 system_modal_window_
->set_id(3);
69 transient_child_
= new aura::Window(&delegate4_
);
70 transient_child_
->SetType(aura::client::WINDOW_TYPE_NORMAL
);
71 transient_child_
->Init(ui::LAYER_NOT_DRAWN
);
72 SetDefaultParentByPrimaryRootWindow(transient_child_
);
73 transient_child_
->set_id(4);
75 transient_parent_
.reset(new aura::Window(&delegate5_
));
76 transient_parent_
->SetType(aura::client::WINDOW_TYPE_NORMAL
);
77 transient_parent_
->Init(ui::LAYER_NOT_DRAWN
);
78 SetDefaultParentByPrimaryRootWindow(transient_parent_
.get());
79 transient_parent_
->AddTransientChild(transient_child_
);
80 transient_parent_
->set_id(5);
82 panel_window_
.reset(new aura::Window(&delegate6_
));
83 panel_window_
->SetType(aura::client::WINDOW_TYPE_PANEL
);
84 panel_window_
->Init(ui::LAYER_NOT_DRAWN
);
85 SetDefaultParentByPrimaryRootWindow(panel_window_
.get());
88 virtual void TearDown() OVERRIDE
{
90 always_on_top_window_
.reset();
91 system_modal_window_
.reset();
92 transient_parent_
.reset();
93 panel_window_
.reset();
94 AshTestBase::TearDown();
98 gfx::Point
CalculateDragPoint(const WindowResizer
& resizer
,
101 gfx::Point location
= resizer
.GetInitialLocation();
102 location
.set_x(location
.x() + delta_x
);
103 location
.set_y(location
.y() + delta_y
);
107 internal::ShelfLayoutManager
* shelf_layout_manager() {
108 return Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
111 static WindowResizer
* CreateDragWindowResizer(
112 aura::Window
* window
,
113 const gfx::Point
& point_in_parent
,
114 int window_component
) {
115 return CreateWindowResizer(
119 aura::client::WINDOW_MOVE_SOURCE_MOUSE
).release();
122 bool WarpMouseCursorIfNecessary(aura::RootWindow
* target_root
,
123 const gfx::Point
& point_in_screen
) {
124 MouseCursorEventFilter
* event_filter
=
125 Shell::GetInstance()->mouse_cursor_filter();
126 bool is_warped
= event_filter
->WarpMouseCursorIfNecessary(target_root
,
128 event_filter
->reset_was_mouse_warped_for_test();
132 aura::test::TestWindowDelegate delegate_
;
133 aura::test::TestWindowDelegate delegate2_
;
134 aura::test::TestWindowDelegate delegate3_
;
135 aura::test::TestWindowDelegate delegate4_
;
136 aura::test::TestWindowDelegate delegate5_
;
137 aura::test::TestWindowDelegate delegate6_
;
139 scoped_ptr
<aura::Window
> window_
;
140 scoped_ptr
<aura::Window
> always_on_top_window_
;
141 scoped_ptr
<aura::Window
> system_modal_window_
;
142 scoped_ptr
<aura::Window
> panel_window_
;
143 aura::Window
* transient_child_
;
144 scoped_ptr
<aura::Window
> transient_parent_
;
147 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest
);
150 // Verifies a window can be moved from the primary display to another.
151 TEST_F(DragWindowResizerTest
, WindowDragWithMultiDisplays
) {
152 if (!SupportsMultipleDisplays())
155 // The secondary display is logically on the right, but on the system (e.g. X)
156 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
157 UpdateDisplay("800x600,800x600");
158 Shell::RootWindowList root_windows
= Shell::GetAllRootWindows();
159 ASSERT_EQ(2U, root_windows
.size());
161 window_
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
162 Shell::GetScreen()->GetPrimaryDisplay());
163 EXPECT_EQ(root_windows
[0], window_
->GetRootWindow());
165 // Grab (0, 0) of the window.
166 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
167 window_
.get(), gfx::Point(), HTCAPTION
));
168 ASSERT_TRUE(resizer
.get());
169 // Drag the pointer to the right. Once it reaches the right edge of the
170 // primary display, it warps to the secondary.
171 resizer
->Drag(CalculateDragPoint(*resizer
, 800, 10), 0);
172 resizer
->CompleteDrag(0);
173 // The whole window is on the secondary display now. The parent should be
175 EXPECT_EQ(root_windows
[1], window_
->GetRootWindow());
176 EXPECT_EQ("0,10 50x60", window_
->bounds().ToString());
179 window_
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
180 Shell::GetScreen()->GetPrimaryDisplay());
181 EXPECT_EQ(root_windows
[0], window_
->GetRootWindow());
183 // Grab (0, 0) of the window and move the pointer to (790, 10).
184 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
185 window_
.get(), gfx::Point(), HTCAPTION
));
186 ASSERT_TRUE(resizer
.get());
187 resizer
->Drag(CalculateDragPoint(*resizer
, 790, 10), 0);
188 resizer
->CompleteDrag(0);
189 // Since the pointer is still on the primary root window, the parent should
191 EXPECT_EQ(root_windows
[0], window_
->GetRootWindow());
192 EXPECT_EQ("790,10 50x60", window_
->bounds().ToString());
195 window_
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
196 Shell::GetScreen()->GetPrimaryDisplay());
197 EXPECT_EQ(root_windows
[0], window_
->GetRootWindow());
199 // Grab the top-right edge of the window and move the pointer to (0, 10)
200 // in the secondary root window's coordinates.
201 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
202 window_
.get(), gfx::Point(49, 0), HTCAPTION
));
203 ASSERT_TRUE(resizer
.get());
204 resizer
->Drag(CalculateDragPoint(*resizer
, 751, 10), ui::EF_CONTROL_DOWN
);
205 resizer
->CompleteDrag(0);
206 // Since the pointer is on the secondary, the parent should be changed
207 // even though only small fraction of the window is within the secondary
208 // root window's bounds.
209 EXPECT_EQ(root_windows
[1], window_
->GetRootWindow());
210 EXPECT_EQ("-49,10 50x60", window_
->bounds().ToString());
214 // Verifies that dragging the active window to another display makes the new
215 // root window the active root window.
216 TEST_F(DragWindowResizerTest
, WindowDragWithMultiDisplaysActiveRoot
) {
217 if (!SupportsMultipleDisplays())
220 // The secondary display is logically on the right, but on the system (e.g. X)
221 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
222 UpdateDisplay("800x600,800x600");
223 Shell::RootWindowList root_windows
= Shell::GetAllRootWindows();
224 ASSERT_EQ(2U, root_windows
.size());
226 aura::test::TestWindowDelegate delegate
;
227 scoped_ptr
<aura::Window
> window(new aura::Window(&delegate
));
228 window
->SetType(aura::client::WINDOW_TYPE_NORMAL
);
229 window
->Init(ui::LAYER_TEXTURED
);
230 SetDefaultParentByPrimaryRootWindow(window
.get());
231 window
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
232 Shell::GetScreen()->GetPrimaryDisplay());
234 EXPECT_TRUE(ash::wm::CanActivateWindow(window
.get()));
235 ash::wm::ActivateWindow(window
.get());
236 EXPECT_EQ(root_windows
[0], window
->GetRootWindow());
237 EXPECT_EQ(root_windows
[0], ash::Shell::GetTargetRootWindow());
239 // Grab (0, 0) of the window.
240 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
241 window
.get(), gfx::Point(), HTCAPTION
));
242 ASSERT_TRUE(resizer
.get());
243 // Drag the pointer to the right. Once it reaches the right edge of the
244 // primary display, it warps to the secondary.
245 resizer
->Drag(CalculateDragPoint(*resizer
, 800, 10), 0);
246 resizer
->CompleteDrag(0);
247 // The whole window is on the secondary display now. The parent should be
249 EXPECT_EQ(root_windows
[1], window
->GetRootWindow());
250 EXPECT_EQ(root_windows
[1], ash::Shell::GetTargetRootWindow());
254 // Verifies a window can be moved from the secondary display to primary.
255 TEST_F(DragWindowResizerTest
, WindowDragWithMultiDisplaysRightToLeft
) {
256 if (!SupportsMultipleDisplays())
259 UpdateDisplay("800x600,800x600");
260 Shell::RootWindowList root_windows
= Shell::GetAllRootWindows();
261 ASSERT_EQ(2U, root_windows
.size());
263 window_
->SetBoundsInScreen(
264 gfx::Rect(800, 00, 50, 60),
265 Shell::GetScreen()->GetDisplayNearestWindow(root_windows
[1]));
266 EXPECT_EQ(root_windows
[1], window_
->GetRootWindow());
268 // Grab (0, 0) of the window.
269 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
270 window_
.get(), gfx::Point(), HTCAPTION
));
271 ASSERT_TRUE(resizer
.get());
272 // Move the mouse near the right edge, (798, 0), of the primary display.
273 resizer
->Drag(CalculateDragPoint(*resizer
, -2, 0), ui::EF_CONTROL_DOWN
);
274 resizer
->CompleteDrag(0);
275 EXPECT_EQ(root_windows
[0], window_
->GetRootWindow());
276 EXPECT_EQ("798,0 50x60", window_
->bounds().ToString());
280 // Verifies the drag window is shown correctly.
281 TEST_F(DragWindowResizerTest
, DragWindowController
) {
282 if (!SupportsMultipleDisplays())
285 UpdateDisplay("800x600,800x600");
286 Shell::RootWindowList root_windows
= Shell::GetAllRootWindows();
287 ASSERT_EQ(2U, root_windows
.size());
289 window_
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
290 Shell::GetScreen()->GetPrimaryDisplay());
291 EXPECT_EQ(root_windows
[0], window_
->GetRootWindow());
292 EXPECT_FLOAT_EQ(1.0f
, window_
->layer()->opacity());
294 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
295 window_
.get(), gfx::Point(), HTCAPTION
));
296 ASSERT_TRUE(resizer
.get());
297 internal::DragWindowResizer
* drag_resizer
= DragWindowResizer::instance_
;
298 ASSERT_TRUE(drag_resizer
);
299 EXPECT_FALSE(drag_resizer
->drag_window_controller_
.get());
301 // The pointer is inside the primary root. The drag window controller
303 resizer
->Drag(CalculateDragPoint(*resizer
, 10, 10), 0);
304 EXPECT_FALSE(drag_resizer
->drag_window_controller_
.get());
306 // The window spans both root windows.
307 resizer
->Drag(CalculateDragPoint(*resizer
, 798, 10), 0);
308 DragWindowController
* controller
=
309 drag_resizer
->drag_window_controller_
.get();
310 ASSERT_TRUE(controller
);
312 ASSERT_TRUE(controller
->drag_widget_
);
313 ui::Layer
* drag_layer
=
314 controller
->drag_widget_
->GetNativeWindow()->layer();
315 ASSERT_TRUE(drag_layer
);
316 // Check if |resizer->layer_| is properly set to the drag widget.
317 const std::vector
<ui::Layer
*>& layers
= drag_layer
->children();
318 EXPECT_FALSE(layers
.empty());
319 EXPECT_EQ(controller
->layer_
, layers
.back());
321 // |window_| should be opaque since the pointer is still on the primary
322 // root window. The drag window should be semi-transparent.
323 EXPECT_FLOAT_EQ(1.0f
, window_
->layer()->opacity());
324 ASSERT_TRUE(controller
->drag_widget_
);
325 EXPECT_GT(1.0f
, drag_layer
->opacity());
327 // Enter the pointer to the secondary display.
328 resizer
->Drag(CalculateDragPoint(*resizer
, 800, 10), 0);
329 controller
= drag_resizer
->drag_window_controller_
.get();
330 ASSERT_TRUE(controller
);
331 // |window_| should be transparent, and the drag window should be opaque.
332 EXPECT_GT(1.0f
, window_
->layer()->opacity());
333 EXPECT_FLOAT_EQ(1.0f
, drag_layer
->opacity());
335 resizer
->CompleteDrag(0);
336 EXPECT_EQ(root_windows
[1], window_
->GetRootWindow());
337 EXPECT_FLOAT_EQ(1.0f
, window_
->layer()->opacity());
340 // Do the same test with RevertDrag().
341 window_
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
342 Shell::GetScreen()->GetPrimaryDisplay());
343 EXPECT_EQ(root_windows
[0], window_
->GetRootWindow());
344 EXPECT_FLOAT_EQ(1.0f
, window_
->layer()->opacity());
346 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
347 window_
.get(), gfx::Point(), HTCAPTION
));
348 ASSERT_TRUE(resizer
.get());
349 internal::DragWindowResizer
* drag_resizer
= DragWindowResizer::instance_
;
350 ASSERT_TRUE(drag_resizer
);
351 EXPECT_FALSE(drag_resizer
->drag_window_controller_
.get());
353 resizer
->Drag(CalculateDragPoint(*resizer
, 0, 610), 0);
354 resizer
->RevertDrag();
355 EXPECT_EQ(root_windows
[0], window_
->GetRootWindow());
356 EXPECT_FLOAT_EQ(1.0f
, window_
->layer()->opacity());
360 // Verifies if the resizer sets and resets
361 // MouseCursorEventFilter::mouse_warp_mode_ as expected.
362 TEST_F(DragWindowResizerTest
, WarpMousePointer
) {
363 MouseCursorEventFilter
* event_filter
=
364 Shell::GetInstance()->mouse_cursor_filter();
365 ASSERT_TRUE(event_filter
);
366 window_
->SetBounds(gfx::Rect(0, 0, 50, 60));
368 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS
,
369 event_filter
->mouse_warp_mode_
);
371 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
372 window_
.get(), gfx::Point(), HTCAPTION
));
373 // While dragging a window, warp should be allowed.
374 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG
,
375 event_filter
->mouse_warp_mode_
);
376 resizer
->CompleteDrag(0);
378 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS
,
379 event_filter
->mouse_warp_mode_
);
382 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
383 window_
.get(), gfx::Point(), HTCAPTION
));
384 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG
,
385 event_filter
->mouse_warp_mode_
);
386 resizer
->RevertDrag();
388 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS
,
389 event_filter
->mouse_warp_mode_
);
392 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
393 window_
.get(), gfx::Point(), HTRIGHT
));
394 // While resizing a window, warp should NOT be allowed.
395 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE
,
396 event_filter
->mouse_warp_mode_
);
397 resizer
->CompleteDrag(0);
399 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS
,
400 event_filter
->mouse_warp_mode_
);
403 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
404 window_
.get(), gfx::Point(), HTRIGHT
));
405 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE
,
406 event_filter
->mouse_warp_mode_
);
407 resizer
->RevertDrag();
409 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS
,
410 event_filter
->mouse_warp_mode_
);
413 // Verifies cursor's device scale factor is updated whe a window is moved across
414 // root windows with different device scale factors (http://crbug.com/154183).
415 TEST_F(DragWindowResizerTest
, CursorDeviceScaleFactor
) {
416 if (!SupportsMultipleDisplays())
419 // The secondary display is logically on the right, but on the system (e.g. X)
420 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
421 UpdateDisplay("400x400,800x800*2");
422 Shell::RootWindowList root_windows
= Shell::GetAllRootWindows();
423 ASSERT_EQ(2U, root_windows
.size());
425 test::CursorManagerTestApi
cursor_test_api(
426 Shell::GetInstance()->cursor_manager());
427 // Move window from the root window with 1.0 device scale factor to the root
428 // window with 2.0 device scale factor.
430 window_
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
431 Shell::GetScreen()->GetPrimaryDisplay());
432 EXPECT_EQ(root_windows
[0], window_
->GetRootWindow());
433 // Grab (0, 0) of the window.
434 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
435 window_
.get(), gfx::Point(), HTCAPTION
));
436 EXPECT_EQ(1.0f
, cursor_test_api
.GetDisplay().device_scale_factor());
437 ASSERT_TRUE(resizer
.get());
438 resizer
->Drag(CalculateDragPoint(*resizer
, 399, 200), 0);
439 WarpMouseCursorIfNecessary(root_windows
[0], gfx::Point(399, 200));
440 EXPECT_EQ(2.0f
, cursor_test_api
.GetDisplay().device_scale_factor());
441 resizer
->CompleteDrag(0);
442 EXPECT_EQ(2.0f
, cursor_test_api
.GetDisplay().device_scale_factor());
445 // Move window from the root window with 2.0 device scale factor to the root
446 // window with 1.0 device scale factor.
448 window_
->SetBoundsInScreen(
449 gfx::Rect(600, 0, 50, 60),
450 Shell::GetScreen()->GetDisplayNearestWindow(root_windows
[1]));
451 EXPECT_EQ(root_windows
[1], window_
->GetRootWindow());
452 // Grab (0, 0) of the window.
453 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
454 window_
.get(), gfx::Point(), HTCAPTION
));
455 EXPECT_EQ(2.0f
, cursor_test_api
.GetDisplay().device_scale_factor());
456 ASSERT_TRUE(resizer
.get());
457 resizer
->Drag(CalculateDragPoint(*resizer
, -200, 200), 0);
458 WarpMouseCursorIfNecessary(root_windows
[1], gfx::Point(400, 200));
459 EXPECT_EQ(1.0f
, cursor_test_api
.GetDisplay().device_scale_factor());
460 resizer
->CompleteDrag(0);
461 EXPECT_EQ(1.0f
, cursor_test_api
.GetDisplay().device_scale_factor());
465 // Verifies several kinds of windows can be moved across displays.
466 TEST_F(DragWindowResizerTest
, MoveWindowAcrossDisplays
) {
467 if (!SupportsMultipleDisplays())
470 // The secondary display is logically on the right, but on the system (e.g. X)
471 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
472 UpdateDisplay("400x400,400x400");
474 Shell::RootWindowList root_windows
= Shell::GetAllRootWindows();
475 ASSERT_EQ(2U, root_windows
.size());
477 // Normal window can be moved across display.
479 aura::Window
* window
= window_
.get();
480 window
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
481 Shell::GetScreen()->GetPrimaryDisplay());
482 // Grab (0, 0) of the window.
483 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
484 window
, gfx::Point(), HTCAPTION
));
485 ASSERT_TRUE(resizer
.get());
486 resizer
->Drag(CalculateDragPoint(*resizer
, 399, 200), 0);
487 EXPECT_TRUE(WarpMouseCursorIfNecessary(root_windows
[0],
488 gfx::Point(399, 200)));
489 resizer
->CompleteDrag(0);
492 // Always on top window can be moved across display.
494 aura::Window
* window
= always_on_top_window_
.get();
495 window
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
496 Shell::GetScreen()->GetPrimaryDisplay());
497 // Grab (0, 0) of the window.
498 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
499 window
, gfx::Point(), HTCAPTION
));
500 ASSERT_TRUE(resizer
.get());
501 resizer
->Drag(CalculateDragPoint(*resizer
, 399, 200), 0);
502 EXPECT_TRUE(WarpMouseCursorIfNecessary(root_windows
[0],
503 gfx::Point(399, 200)));
504 resizer
->CompleteDrag(0);
507 // System modal window can be moved across display.
509 aura::Window
* window
= system_modal_window_
.get();
510 window
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
511 Shell::GetScreen()->GetPrimaryDisplay());
512 // Grab (0, 0) of the window.
513 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
514 window
, gfx::Point(), HTCAPTION
));
515 ASSERT_TRUE(resizer
.get());
516 resizer
->Drag(CalculateDragPoint(*resizer
, 399, 200), 0);
517 EXPECT_TRUE(WarpMouseCursorIfNecessary(root_windows
[0],
518 gfx::Point(399, 200)));
519 resizer
->CompleteDrag(0);
522 // Transient window cannot be moved across display.
524 aura::Window
* window
= transient_child_
;
525 window
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
526 Shell::GetScreen()->GetPrimaryDisplay());
527 // Grab (0, 0) of the window.
528 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
529 window
, gfx::Point(), HTCAPTION
));
530 ASSERT_TRUE(resizer
.get());
531 resizer
->Drag(CalculateDragPoint(*resizer
, 399, 200), 0);
532 EXPECT_FALSE(WarpMouseCursorIfNecessary(
534 gfx::Point(399, 200)));
535 resizer
->CompleteDrag(0);
538 // The parent of transient window can be moved across display.
540 aura::Window
* window
= transient_parent_
.get();
541 window
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
542 Shell::GetScreen()->GetPrimaryDisplay());
543 // Grab (0, 0) of the window.
544 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
545 window
, gfx::Point(), HTCAPTION
));
546 ASSERT_TRUE(resizer
.get());
547 resizer
->Drag(CalculateDragPoint(*resizer
, 399, 200), 0);
548 EXPECT_TRUE(WarpMouseCursorIfNecessary(root_windows
[0],
549 gfx::Point(399, 200)));
550 resizer
->CompleteDrag(0);
553 // Panel window can be moved across display.
555 aura::Window
* window
= panel_window_
.get();
556 window
->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
557 Shell::GetScreen()->GetPrimaryDisplay());
558 // Grab (0, 0) of the window.
559 scoped_ptr
<WindowResizer
> resizer(CreateDragWindowResizer(
560 window
, gfx::Point(), HTCAPTION
));
561 ASSERT_TRUE(resizer
.get());
562 resizer
->Drag(CalculateDragPoint(*resizer
, 399, 200), 0);
563 EXPECT_TRUE(WarpMouseCursorIfNecessary(root_windows
[0],
564 gfx::Point(399, 200)));
565 resizer
->CompleteDrag(0);
569 } // namespace internal