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

Side by Side Diff: ash/wm/dock/docked_window_resizer_unittest.cc

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dock with zero width (rebase) Created 7 years, 6 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 unified diff | Download patch
« no previous file with comments | « ash/wm/dock/docked_window_resizer.cc ('k') | ash/wm/drag_window_resizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 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/wm/dock/docked_window_resizer.h"
6
7 #include "ash/ash_switches.h"
8 #include "ash/launcher/launcher.h"
9 #include "ash/launcher/launcher_model.h"
10 #include "ash/root_window_controller.h"
11 #include "ash/shelf/shelf_layout_manager.h"
12 #include "ash/shelf/shelf_types.h"
13 #include "ash/shelf/shelf_widget.h"
14 #include "ash/shell.h"
15 #include "ash/shell_window_ids.h"
16 #include "ash/test/ash_test_base.h"
17 #include "ash/test/cursor_manager_test_api.h"
18 #include "ash/test/shell_test_api.h"
19 #include "ash/test/test_launcher_delegate.h"
20 #include "ash/wm/dock/docked_window_layout_manager.h"
21 #include "ash/wm/drag_window_resizer.h"
22 #include "ash/wm/panels/panel_layout_manager.h"
23 #include "ash/wm/window_properties.h"
24 #include "base/command_line.h"
25 #include "ui/aura/client/aura_constants.h"
26 #include "ui/aura/root_window.h"
27 #include "ui/base/hit_test.h"
28 #include "ui/base/ui_base_types.h"
29 #include "ui/views/widget/widget.h"
30
31 namespace ash {
32 namespace internal {
33
34 class DockedWindowResizerTest
35 : public test::AshTestBase,
36 public testing::WithParamInterface<aura::client::WindowType> {
37 public:
38 DockedWindowResizerTest() : model_(NULL), window_type_(GetParam()) {}
39 virtual ~DockedWindowResizerTest() {}
40
41 virtual void SetUp() OVERRIDE {
42 CommandLine::ForCurrentProcess()->AppendSwitch(
43 ash::switches::kAshEnableStickyEdges);
44 CommandLine::ForCurrentProcess()->AppendSwitch(
45 ash::switches::kAshEnableDockedWindows);
46 AshTestBase::SetUp();
47 UpdateDisplay("600x400");
48 test::ShellTestApi test_api(Shell::GetInstance());
49 model_ = test_api.launcher_model();
50 }
51
52 virtual void TearDown() OVERRIDE {
53 AshTestBase::TearDown();
54 }
55
56 protected:
57 enum DockedEdge {
58 DOCKED_EDGE_NONE,
59 DOCKED_EDGE_LEFT,
60 DOCKED_EDGE_RIGHT,
61 };
62
63 enum DockedState {
64 UNDOCKED,
65 DOCKED,
66 };
67
68 aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
69 aura::Window* window = CreateTestWindowInShellWithDelegateAndType(
70 NULL,
71 window_type_,
72 0,
73 bounds);
74 if (window_type_ == aura::client::WINDOW_TYPE_PANEL) {
75 test::TestLauncherDelegate* launcher_delegate =
76 test::TestLauncherDelegate::instance();
77 launcher_delegate->AddLauncherItem(window);
78 PanelLayoutManager* manager =
79 static_cast<PanelLayoutManager*>(
80 Shell::GetContainer(window->GetRootWindow(),
81 internal::kShellWindowId_PanelContainer)->
82 layout_manager());
83 manager->Relayout();
84 }
85 return window;
86 }
87
88 static WindowResizer* CreateSomeWindowResizer(
89 aura::Window* window,
90 const gfx::Point& point_in_parent,
91 int window_component) {
92 return CreateWindowResizer(
93 window,
94 point_in_parent,
95 window_component,
96 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release();
97 }
98
99 void DragStart(aura::Window* window) {
100 initial_location_in_parent_ = window->bounds().origin();
101 resizer_.reset(CreateSomeWindowResizer(window,
102 initial_location_in_parent_,
103 HTCAPTION));
104 ASSERT_TRUE(resizer_.get());
105 }
106
107 void DragStartAtOffsetFromwindowOrigin(aura::Window* window,
108 int dx,
109 int dy) {
110 initial_location_in_parent_ =
111 window->bounds().origin() + gfx::Vector2d(dx, dy);
112 resizer_.reset(CreateSomeWindowResizer(window,
113 initial_location_in_parent_,
114 HTCAPTION));
115 ASSERT_TRUE(resizer_.get());
116 }
117
118 void DragMove(int dx, int dy) {
119 resizer_->Drag(initial_location_in_parent_ + gfx::Vector2d(dx, dy), 0);
120 }
121
122 void DragEnd() {
123 resizer_->CompleteDrag(0);
124 resizer_.reset();
125 }
126
127 void DragRevert() {
128 resizer_->RevertDrag();
129 resizer_.reset();
130 }
131
132 // Panels are parented by panel container during drags.
133 // Docked windows are parented by dock container during drags.
134 // All other windows that we are testing here have workspace as a parent.
135 int CorrectContainerIdDuringDrag(DockedState is_docked) {
136 if (window_type_ == aura::client::WINDOW_TYPE_PANEL)
137 return internal::kShellWindowId_PanelContainer;
138 if (is_docked == DOCKED)
139 return internal::kShellWindowId_DockedContainer;
140 return internal::kShellWindowId_WorkspaceContainer;
141 }
142
143 // Test dragging the window vertically (to detach if it is a panel) and then
144 // horizontally to the edge with an added offset from the edge of |dx|.
145 void DragRelativeToEdge(DockedEdge edge,
146 aura::Window* window,
147 int dx) {
148 DragVerticallyAndRelativeToEdge(
149 edge,
150 window,
151 dx,
152 window_type_ == aura::client::WINDOW_TYPE_PANEL ? -100 : 20);
153 }
154
155 void DragToVerticalOffsetAndToEdge(DockedEdge edge,
156 aura::Window* window,
157 int y) {
158 gfx::Rect initial_bounds = window->GetBoundsInScreen();
159 DragVerticallyAndRelativeToEdge(edge, window, 0, y - initial_bounds.y());
160 }
161
162 // Detach if our window is a panel, then drag it vertically by |dy| and
163 // horizontally to the edge with an added offset from the edge of |dx|.
164 void DragVerticallyAndRelativeToEdge(DockedEdge edge,
165 aura::Window* window,
166 int dx,
167 int dy) {
168 aura::RootWindow* root_window = window->GetRootWindow();
169 gfx::Rect initial_bounds = window->GetBoundsInScreen();
170
171 if (window_type_ == aura::client::WINDOW_TYPE_PANEL) {
172 ASSERT_NO_FATAL_FAILURE(DragStart(window));
173 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey));
174
175 // Drag enough to detach since our tests assume panels to be initially
176 // detached.
177 DragMove(0, dy);
178 EXPECT_EQ(CorrectContainerIdDuringDrag(UNDOCKED), window->parent()->id());
179 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x());
180 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y());
181
182 // The panel should be detached when the drag completes.
183 DragEnd();
184
185 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey));
186 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
187 window->parent()->id());
188 EXPECT_EQ(root_window, window->GetRootWindow());
189 }
190
191 // avoid snap by clicking away from the border
192 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 5, 5));
193
194 // Drag the window left or right to the edge (or almost to it).
195 if (edge == DOCKED_EDGE_LEFT)
196 dx += window->GetRootWindow()->bounds().x() - initial_bounds.x();
197 else if (edge == DOCKED_EDGE_RIGHT)
198 dx += window->GetRootWindow()->bounds().right() - initial_bounds.right();
199 DragMove(dx, window_type_ == aura::client::WINDOW_TYPE_PANEL ? 0 : dy);
200 EXPECT_EQ(CorrectContainerIdDuringDrag(UNDOCKED), window->parent()->id());
201 // Release the mouse and the panel should be attached to the dock.
202 DragEnd();
203
204 // x-coordinate can get adjusted by snapping or sticking.
205 // y-coordinate should not change by possible docking.
206 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y());
207 }
208
209 bool test_panels() const {
210 return window_type_ == aura::client::WINDOW_TYPE_PANEL;
211 }
212
213 private:
214 scoped_ptr<WindowResizer> resizer_;
215 LauncherModel* model_;
216 aura::client::WindowType window_type_;
217
218 // Location at start of the drag in |window->parent()|'s coordinates.
219 gfx::Point initial_location_in_parent_;
220
221 DISALLOW_COPY_AND_ASSIGN(DockedWindowResizerTest);
222 };
223
224 // Verifies a window can be dragged and attached to the dock.
225 TEST_P(DockedWindowResizerTest, AttachRightPrecise) {
226 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
227 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
228
229 // The window should be attached and snapped to the right edge.
230 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
231 window->GetBoundsInScreen().right());
232 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
233 }
234
235 // Verifies a window can be dragged and attached to the dock
236 // even if we overshoot the screen edge by a few pixels (sticky edge)
237 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) {
238 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
239 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4);
240
241 // The window should be attached and snapped to the right edge.
242 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
243 window->GetBoundsInScreen().right());
244 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
245 }
246
247 // Verifies a window can be dragged and then if not quite reaching the screen
248 // edge it does not get docked to a screen edge and stays in the workspace.
249 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) {
250 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
251 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), -1);
252
253 // The window should not be attached to the dock.
254 EXPECT_EQ(window->GetRootWindow()->bounds().right() - 1,
255 window->GetBoundsInScreen().right());
256 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
257 window->parent()->id());
258 }
259
260 // Verifies a window can be dragged and attached to the dock.
261 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) {
262 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
263 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0);
264
265 // The window should be attached and snapped to the left dock.
266 EXPECT_EQ(window->GetRootWindow()->bounds().x(),
267 window->GetBoundsInScreen().x());
268 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
269 }
270
271 // Verifies a window can be dragged and attached to the dock
272 // even if we overshoot the screen edge by a few pixels (sticky edge)
273 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) {
274 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
275 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4);
276
277 // The window should be attached and snapped to the left dock.
278 EXPECT_EQ(window->GetRootWindow()->bounds().x(),
279 window->GetBoundsInScreen().x());
280 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
281 }
282
283 // Verifies a window can be dragged and then if not quite reaching the screen
284 // edge it does not get docked to a screen edge and stays in the workspace.
285 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) {
286 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
287 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1);
288
289 // The window should not be attached to the dock.
290 EXPECT_EQ(window->GetRootWindow()->bounds().x() + 1,
291 window->GetBoundsInScreen().x());
292 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
293 window->parent()->id());
294 }
295
296 // Dock on the right side, change shelf alignment, check that windows move to
297 // the opposite side.
298 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) {
299 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
300 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
301
302 // The window should be attached and snapped to the right edge.
303 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
304 window->GetBoundsInScreen().right());
305 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
306
307 // set launcher shelf to be aligned on the right
308 ash::Shell* shell = ash::Shell::GetInstance();
309 shell->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT,
310 shell->GetPrimaryRootWindow());
311 // The window should have moved and get attached to the left dock.
312 EXPECT_EQ(window->GetRootWindow()->bounds().x(),
313 window->GetBoundsInScreen().x());
314 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
315
316 // set launcher shelf to be aligned on the left
317 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT,
318 shell->GetPrimaryRootWindow());
319 // The window should have moved and get attached to the right edge.
320 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
321 window->GetBoundsInScreen().right());
322 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
323
324 // set launcher shelf to be aligned at the bottom
325 shell->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM,
326 shell->GetPrimaryRootWindow());
327 // The window should stay in the right edge.
328 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
329 window->GetBoundsInScreen().right());
330 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
331 }
332
333 // Dock on the right side, try to undock, then drag more to really undock
334 TEST_P(DockedWindowResizerTest, AttachTryDetach) {
335 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
336 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
337
338 // The window should be attached and snapped to the right edge.
339 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
340 window->GetBoundsInScreen().right());
341 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
342
343 // Try to detach by dragging left a bit (should stay docked)
344 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
345 DragMove(-10, -10);
346 // Release the mouse and the window should be still attached to the dock.
347 DragEnd();
348
349 // The window should be still attached to the right edge.
350 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
351 window->GetBoundsInScreen().right());
352 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
353
354 // Try to detach by dragging left a bit more (should get undocked)
355 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
356 DragMove(-32, -10);
357 // Release the mouse and the window should be no longer attached to the dock.
358 DragEnd();
359
360 // The window should be floating on a workspace again.
361 EXPECT_EQ(window->GetRootWindow()->bounds().right() - 32,
362 window->GetBoundsInScreen().right());
363 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
364 window->parent()->id());
365 }
366
367 // Minimize a docked window, then restore it and check that it is still docked.
368 TEST_P(DockedWindowResizerTest, AttachMinimizeRestore) {
369 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
370 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
371
372 // The window should be attached and snapped to the right edge.
373 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
374 window->GetBoundsInScreen().right());
375 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
376
377 // Minimize the window, it should be hidden.
378 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
379 RunAllPendingInMessageLoop();
380 EXPECT_FALSE(window->IsVisible());
381 // Restore the window; window should be visible.
382 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
383 RunAllPendingInMessageLoop();
384 EXPECT_TRUE(window->IsVisible());
385 }
386
387 // Dock two windows, undock one, check that the other one is still docked.
388 #if defined(OS_WIN)
389 // TODO(varkha): Positioning of the panel seems to be off on Windows Aura when
390 // attached to the right (http://crbug.com/180892).
391 TEST_P(DockedWindowResizerTest, DISABLED_AttachTwoWindows)
392 #else
393 TEST_P(DockedWindowResizerTest, AttachTwoWindows)
394 #endif
395 {
396 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
397 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
398 DragToVerticalOffsetAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
399 DragToVerticalOffsetAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 50);
400
401 // Both windows should be attached and snapped to the right edge.
402 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
403 w1->GetBoundsInScreen().right());
404 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
405
406 EXPECT_EQ(w2->GetRootWindow()->bounds().right(),
407 w2->GetBoundsInScreen().right());
408 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id());
409
410 // Detach by dragging left (should get undocked)
411 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get()));
412 DragMove(-32, -10);
413 // Release the mouse and the window should be no longer attached to the edge.
414 DragEnd();
415
416 // The first window should be still docked.
417 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
418 w1->GetBoundsInScreen().right());
419 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
420
421 // The second window should be floating on a workspace again.
422 EXPECT_EQ(w2->GetRootWindow()->bounds().right() - 32,
423 w2->GetBoundsInScreen().right());
424 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
425 w2->parent()->id());
426 }
427
428 // Dock one window, try to dock another window on the opposite side (should not
429 // dock).
430 #if defined(OS_WIN)
431 // TODO(varkha): Positioning of the panel seems to be off on Windows Aura when
432 // attached to the right (http://crbug.com/180892).
433 TEST_P(DockedWindowResizerTest, DISABLED_AttachOnTwoSides)
434 #else
435 TEST_P(DockedWindowResizerTest, AttachOnTwoSides)
436 #endif
437 {
438 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
439 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
440 DragToVerticalOffsetAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
441 DragToVerticalOffsetAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50);
442
443 // The first window should be attached and snapped to the right edge.
444 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
445 w1->GetBoundsInScreen().right());
446 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
447
448 // The second window should be near the left edge but not snapped.
449 EXPECT_EQ(w2->GetRootWindow()->bounds().x(), w2->GetBoundsInScreen().x());
450 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, w2->parent()->id());
451 }
452
453 // Reverting drag
454 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) {
455 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
456 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
457
458 // The window should be attached and snapped to the right edge.
459 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
460 window->GetBoundsInScreen().right());
461 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
462
463 // Drag the window out but revert the drag
464 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
465 DragMove(-50, 0);
466 DragRevert();
467 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
468
469 // Detach window.
470 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
471 DragMove(-50, 0);
472 DragEnd();
473 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
474 window->parent()->id());
475 }
476
477 // Move a docked window to the second display
478 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) {
479 if (!SupportsMultipleDisplays())
480 return;
481
482 UpdateDisplay("800x800,800x800");
483 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
484 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
485 gfx::Rect initial_bounds = window->GetBoundsInScreen();
486 EXPECT_EQ(root_windows[0], window->GetRootWindow());
487
488 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
489 // The window should be attached and snapped to the right edge.
490 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
491 window->GetBoundsInScreen().right());
492 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
493
494 // Undock and move to the right - enough to get it peeking at the other screen
495 // but not enough to land in the other screen
496 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
497 DragMove(50, 0);
498 EXPECT_EQ(CorrectContainerIdDuringDrag(DOCKED), window->parent()->id());
499 DragEnd();
500 EXPECT_NE(window->GetRootWindow()->bounds().right(),
501 window->GetBoundsInScreen().right());
502 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
503 window->parent()->id());
504 EXPECT_EQ(root_windows[0], window->GetRootWindow());
505
506 // Move back left - should dock again.
507 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
508 DragMove(-50, 0);
509 EXPECT_EQ(CorrectContainerIdDuringDrag(UNDOCKED), window->parent()->id());
510 DragEnd();
511 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
512 window->GetBoundsInScreen().right());
513 EXPECT_EQ(internal::kShellWindowId_DockedContainer,
514 window->parent()->id());
515 EXPECT_EQ(root_windows[0], window->GetRootWindow());
516
517 // Undock and move to the right - enough to get the mouse pointer past the
518 // edge of the screen and into the second screen. The window should now be
519 // in the second screen and not docked.
520 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(
521 window.get(),
522 window->bounds().width()/2 + 10,
523 0));
524 DragMove(window->bounds().width()/2 - 5, 0);
525 EXPECT_EQ(CorrectContainerIdDuringDrag(DOCKED), window->parent()->id());
526 DragEnd();
527 EXPECT_NE(window->GetRootWindow()->bounds().right(),
528 window->GetBoundsInScreen().right());
529 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
530 window->parent()->id());
531 EXPECT_EQ(root_windows[1], window->GetRootWindow());
532
533 // Keep dragging it to the right until it docks. The window should now be
534 // in the second screen.
535 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(
536 window.get(),
537 window->bounds().width()/2 + 10,
538 0));
539 DragMove(window->GetRootWindow()->GetBoundsInScreen().x() -
540 window->GetBoundsInScreen().x(),
541 0);
542 EXPECT_EQ(CorrectContainerIdDuringDrag(UNDOCKED), window->parent()->id());
543 DragEnd();
544 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(),
545 window->GetBoundsInScreen().x());
546 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
547 EXPECT_EQ(root_windows[1], window->GetRootWindow());
548 }
549
550 // Tests run twice - on both panels and normal windows
551 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
552 DockedWindowResizerTest,
553 testing::Values(aura::client::WINDOW_TYPE_NORMAL,
554 aura::client::WINDOW_TYPE_PANEL));
555 } // namespace internal
556 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/dock/docked_window_resizer.cc ('k') | ash/wm/drag_window_resizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698