OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/wm/dock/docked_window_resizer.h" | 5 #include "ash/wm/dock/docked_window_resizer.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
9 #include "ash/launcher/launcher_model.h" | 9 #include "ash/launcher/launcher_model.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 const gfx::Point& point_in_parent, | 88 const gfx::Point& point_in_parent, |
89 int window_component) { | 89 int window_component) { |
90 return CreateWindowResizer( | 90 return CreateWindowResizer( |
91 window, | 91 window, |
92 point_in_parent, | 92 point_in_parent, |
93 window_component, | 93 window_component, |
94 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release(); | 94 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release(); |
95 } | 95 } |
96 | 96 |
97 void DragStart(aura::Window* window) { | 97 void DragStart(aura::Window* window) { |
98 initial_location_in_parent_ = window->bounds().origin(); | 98 DragStartAtOffsetFromwindowOrigin(window, 0, 0); |
99 resizer_.reset(CreateSomeWindowResizer(window, | |
100 initial_location_in_parent_, | |
101 HTCAPTION)); | |
102 ASSERT_TRUE(resizer_.get()); | |
103 } | 99 } |
104 | 100 |
105 void DragStartAtOffsetFromwindowOrigin(aura::Window* window, | 101 void DragStartAtOffsetFromwindowOrigin(aura::Window* window, |
106 int dx, | 102 int dx, |
107 int dy) { | 103 int dy) { |
108 initial_location_in_parent_ = | 104 initial_location_in_parent_ = |
109 window->bounds().origin() + gfx::Vector2d(dx, dy); | 105 window->bounds().origin() + gfx::Vector2d(dx, dy); |
110 resizer_.reset(CreateSomeWindowResizer(window, | 106 resizer_.reset(CreateSomeWindowResizer(window, |
111 initial_location_in_parent_, | 107 initial_location_in_parent_, |
112 HTCAPTION)); | 108 HTCAPTION)); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // Detach if our window is a panel, then drag it vertically by |dy| and | 173 // Detach if our window is a panel, then drag it vertically by |dy| and |
178 // horizontally to the edge with an added offset from the edge of |dx|. | 174 // horizontally to the edge with an added offset from the edge of |dx|. |
179 void DragVerticallyAndRelativeToEdge(DockedEdge edge, | 175 void DragVerticallyAndRelativeToEdge(DockedEdge edge, |
180 aura::Window* window, | 176 aura::Window* window, |
181 int dx, | 177 int dx, |
182 int dy) { | 178 int dy) { |
183 aura::RootWindow* root_window = window->GetRootWindow(); | 179 aura::RootWindow* root_window = window->GetRootWindow(); |
184 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 180 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
185 | 181 |
186 if (window_type_ == aura::client::WINDOW_TYPE_PANEL) { | 182 if (window_type_ == aura::client::WINDOW_TYPE_PANEL) { |
187 ASSERT_NO_FATAL_FAILURE(DragStart(window)); | 183 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5)); |
188 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); | 184 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); |
189 | 185 |
190 // Drag enough to detach since our tests assume panels to be initially | 186 // Drag enough to detach since our tests assume panels to be initially |
191 // detached. | 187 // detached. |
192 DragMove(0, dy); | 188 DragMove(0, dy); |
193 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 189 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
194 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); | 190 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); |
195 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); | 191 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); |
196 | 192 |
197 // The panel should be detached when the drag completes. | 193 // The panel should be detached when the drag completes. |
198 DragEnd(); | 194 DragEnd(); |
199 | 195 |
200 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 196 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
201 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, | 197 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, |
202 window->parent()->id()); | 198 window->parent()->id()); |
203 EXPECT_EQ(root_window, window->GetRootWindow()); | 199 EXPECT_EQ(root_window, window->GetRootWindow()); |
204 } | 200 } |
205 | 201 |
206 // avoid snap by clicking away from the border | 202 // avoid snap by clicking away from the border |
207 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5)); | 203 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5)); |
208 | 204 |
| 205 gfx::Rect work_area = |
| 206 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); |
209 // Drag the window left or right to the edge (or almost to it). | 207 // Drag the window left or right to the edge (or almost to it). |
210 if (edge == DOCKED_EDGE_LEFT) | 208 if (edge == DOCKED_EDGE_LEFT) |
211 dx += window->GetRootWindow()->bounds().x() - initial_bounds.x(); | 209 dx += work_area.x() - initial_location_in_parent_.x(); |
212 else if (edge == DOCKED_EDGE_RIGHT) | 210 else if (edge == DOCKED_EDGE_RIGHT) |
213 dx += window->GetRootWindow()->bounds().right() - initial_bounds.right(); | 211 dx += work_area.right() - 1 - initial_location_in_parent_.x(); |
214 DragMove(dx, window_type_ == aura::client::WINDOW_TYPE_PANEL ? 0 : dy); | 212 DragMove(dx, window_type_ == aura::client::WINDOW_TYPE_PANEL ? 0 : dy); |
215 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 213 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
216 // Release the mouse and the panel should be attached to the dock. | 214 // Release the mouse and the panel should be attached to the dock. |
217 DragEnd(); | 215 DragEnd(); |
218 | 216 |
219 // x-coordinate can get adjusted by snapping or sticking. | 217 // x-coordinate can get adjusted by snapping or sticking. |
220 // y-coordinate could be changed by possible automatic layout if docked. | 218 // y-coordinate could be changed by possible automatic layout if docked. |
221 if (window->parent()->id() != internal::kShellWindowId_DockedContainer) | 219 if (window->parent()->id() != internal::kShellWindowId_DockedContainer && |
| 220 GetRestoreBoundsInScreen(window) == NULL) { |
222 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); | 221 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); |
| 222 } |
223 } | 223 } |
224 | 224 |
225 bool test_panels() const { | 225 bool test_panels() const { |
226 return window_type_ == aura::client::WINDOW_TYPE_PANEL; | 226 return window_type_ == aura::client::WINDOW_TYPE_PANEL; |
227 } | 227 } |
228 | 228 |
229 private: | 229 private: |
230 scoped_ptr<WindowResizer> resizer_; | 230 scoped_ptr<WindowResizer> resizer_; |
231 LauncherModel* model_; | 231 LauncherModel* model_; |
232 aura::client::WindowType window_type_; | 232 aura::client::WindowType window_type_; |
(...skipping 13 matching lines...) Expand all Loading... |
246 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 246 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
247 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 247 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
248 | 248 |
249 // The window should be attached and snapped to the right edge. | 249 // The window should be attached and snapped to the right edge. |
250 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 250 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
251 window->GetBoundsInScreen().right()); | 251 window->GetBoundsInScreen().right()); |
252 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 252 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
253 } | 253 } |
254 | 254 |
255 // Verifies a window can be dragged and attached to the dock | 255 // Verifies a window can be dragged and attached to the dock |
256 // even if we overshoot the screen edge by a few pixels (sticky edge) | 256 // even if pointer overshoots the screen edge by a few pixels (sticky edge) |
257 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) { | 257 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) { |
258 if (!SupportsHostWindowResize()) | 258 if (!SupportsHostWindowResize()) |
259 return; | 259 return; |
260 | 260 |
261 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 261 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
262 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4); | 262 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4); |
263 | 263 |
264 // The window should be attached and snapped to the right edge. | 264 // The window should be attached and snapped to the right edge. |
265 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 265 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
266 window->GetBoundsInScreen().right()); | 266 window->GetBoundsInScreen().right()); |
267 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 267 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
268 } | 268 } |
269 | 269 |
270 // Verifies a window can be dragged and then if not quite reaching the screen | 270 // Verifies a window can be dragged and then if a pointer is not quite reaching |
271 // edge it does not get docked to a screen edge and stays in the desktop. | 271 // the screen edge the window does not get docked and stays in the desktop. |
272 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) { | 272 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) { |
273 if (!SupportsHostWindowResize()) | 273 if (!SupportsHostWindowResize()) |
274 return; | 274 return; |
275 | 275 |
276 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 276 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
277 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), -1); | 277 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), -1); |
278 | 278 |
279 // The window should not be attached to the dock. | 279 // The window right should be past the screen edge but not docked. |
280 EXPECT_EQ(window->GetRootWindow()->bounds().right() - 1, | 280 // Initial touch point is 25px to the right which helps to find where the edge |
| 281 // should be. |
| 282 EXPECT_EQ(window->GetRootWindow()->bounds().right() + 201 - 25 - 1 - 1, |
281 window->GetBoundsInScreen().right()); | 283 window->GetBoundsInScreen().right()); |
282 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, | 284 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, |
283 window->parent()->id()); | 285 window->parent()->id()); |
284 } | 286 } |
285 | 287 |
286 // Verifies a window can be dragged and attached to the dock. | 288 // Verifies a window can be dragged and attached to the dock. |
287 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { | 289 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { |
288 if (!SupportsHostWindowResize()) | 290 if (!SupportsHostWindowResize()) |
289 return; | 291 return; |
290 | 292 |
291 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 293 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
292 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); | 294 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); |
293 | 295 |
294 // The window should be attached and snapped to the left dock. | 296 // The window should be attached and snapped to the left dock. |
295 EXPECT_EQ(window->GetRootWindow()->bounds().x(), | 297 EXPECT_EQ(window->GetRootWindow()->bounds().x(), |
296 window->GetBoundsInScreen().x()); | 298 window->GetBoundsInScreen().x()); |
297 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 299 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
298 } | 300 } |
299 | 301 |
300 // Verifies a window can be dragged and attached to the dock | 302 // Verifies a window can be dragged and attached to the dock |
301 // even if we overshoot the screen edge by a few pixels (sticky edge) | 303 // even if pointer overshoots the screen edge by a few pixels (sticky edge) |
302 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) { | 304 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) { |
303 if (!SupportsHostWindowResize()) | 305 if (!SupportsHostWindowResize()) |
304 return; | 306 return; |
305 | 307 |
306 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 308 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
307 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4); | 309 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4); |
308 | 310 |
309 // The window should be attached and snapped to the left dock. | 311 // The window should be attached and snapped to the left dock. |
310 EXPECT_EQ(window->GetRootWindow()->bounds().x(), | 312 EXPECT_EQ(window->GetRootWindow()->bounds().x(), |
311 window->GetBoundsInScreen().x()); | 313 window->GetBoundsInScreen().x()); |
312 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 314 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
313 } | 315 } |
314 | 316 |
315 // Verifies a window can be dragged and then if not quite reaching the screen | 317 // Verifies a window can be dragged and then if a pointer is not quite reaching |
316 // edge it does not get docked to a screen edge and stays in the desktop. | 318 // the screen edge the window does not get docked and stays in the desktop. |
317 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) { | 319 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) { |
318 if (!SupportsHostWindowResize()) | 320 if (!SupportsHostWindowResize()) |
319 return; | 321 return; |
320 | 322 |
321 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 323 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
322 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1); | 324 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1); |
323 | 325 |
324 // The window should not be attached to the dock. | 326 // The window should be touching the screen edge but not docked. |
325 EXPECT_EQ(window->GetRootWindow()->bounds().x() + 1, | 327 EXPECT_EQ(window->GetRootWindow()->bounds().x(), |
326 window->GetBoundsInScreen().x()); | 328 window->GetBoundsInScreen().x()); |
327 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, | 329 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, |
328 window->parent()->id()); | 330 window->parent()->id()); |
329 } | 331 } |
330 | 332 |
331 // Dock on the right side, change shelf alignment, check that windows move to | 333 // Dock on the right side, change shelf alignment, check that windows move to |
332 // the opposite side. | 334 // the opposite side. |
333 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) { | 335 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) { |
334 if (!SupportsHostWindowResize()) | 336 if (!SupportsHostWindowResize()) |
335 return; | 337 return; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 482 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
481 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 483 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
482 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); | 484 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); |
483 | 485 |
484 // The first window should be attached and snapped to the right edge. | 486 // The first window should be attached and snapped to the right edge. |
485 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 487 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
486 w1->GetBoundsInScreen().right()); | 488 w1->GetBoundsInScreen().right()); |
487 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 489 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
488 | 490 |
489 // The second window should be near the left edge but not snapped. | 491 // The second window should be near the left edge but not snapped. |
| 492 // Normal window will get side-maximized while panels will not. |
490 EXPECT_EQ(w2->GetRootWindow()->bounds().x(), w2->GetBoundsInScreen().x()); | 493 EXPECT_EQ(w2->GetRootWindow()->bounds().x(), w2->GetBoundsInScreen().x()); |
491 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); | 494 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); |
492 } | 495 } |
493 | 496 |
494 // Reverting drag | 497 // Reverting drag |
495 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { | 498 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { |
496 if (!SupportsHostWindowResize()) | 499 if (!SupportsHostWindowResize()) |
497 return; | 500 return; |
498 | 501 |
499 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 502 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
(...skipping 18 matching lines...) Expand all Loading... |
518 window->parent()->id()); | 521 window->parent()->id()); |
519 } | 522 } |
520 | 523 |
521 // Move a docked window to the second display | 524 // Move a docked window to the second display |
522 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { | 525 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { |
523 if (!SupportsMultipleDisplays()) | 526 if (!SupportsMultipleDisplays()) |
524 return; | 527 return; |
525 | 528 |
526 UpdateDisplay("800x800,800x800"); | 529 UpdateDisplay("800x800,800x800"); |
527 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 530 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 531 EXPECT_EQ(2, static_cast<int>(root_windows.size())); |
528 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 532 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
529 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 533 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
530 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 534 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
531 | 535 |
532 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 536 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
533 // The window should be attached and snapped to the right edge. | 537 // The window should be attached and snapped to the right edge. |
534 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 538 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
535 window->GetBoundsInScreen().right()); | 539 window->GetBoundsInScreen().right()); |
536 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 540 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
537 | 541 |
538 // Undock and move to the right - enough to get it peeking at the other screen | 542 // Try dragging to the right - enough to get it peeking at the other screen |
539 // but not enough to land in the other screen | 543 // but not enough to land in the other screen. |
| 544 // The window should stay on the left screen. |
540 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 545 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
541 DragMove(70, 0); | 546 DragMove(100, 0); |
542 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | |
543 DragEnd(); | |
544 EXPECT_NE(window->GetRootWindow()->bounds().right(), | |
545 window->GetBoundsInScreen().right()); | |
546 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, | |
547 window->parent()->id()); | |
548 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | |
549 | |
550 // Move back left - should dock again. | |
551 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | |
552 DragMove(-70, 0); | |
553 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 547 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
554 DragEnd(); | 548 DragEnd(); |
555 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 549 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
556 window->GetBoundsInScreen().right()); | 550 window->GetBoundsInScreen().right()); |
557 EXPECT_EQ(internal::kShellWindowId_DockedContainer, | 551 EXPECT_EQ(internal::kShellWindowId_DockedContainer, |
558 window->parent()->id()); | 552 window->parent()->id()); |
559 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 553 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
560 | 554 |
561 // Undock and move to the right - enough to get the mouse pointer past the | 555 // Undock and move to the right - enough to get the mouse pointer past the |
562 // edge of the screen and into the second screen. The window should now be | 556 // edge of the screen and into the second screen. The window should now be |
563 // in the second screen and not docked. | 557 // in the second screen and not docked. |
564 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin( | 558 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin( |
565 window.get(), | 559 window.get(), |
566 window->bounds().width()/2 + 10, | 560 window->bounds().width()/2 + 10, |
567 0)); | 561 0)); |
568 DragMove(window->bounds().width()/2 - 5, 0); | 562 DragMove(window->bounds().width()/2 - 5, 0); |
569 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 563 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
570 DragEnd(); | 564 DragEnd(); |
571 EXPECT_NE(window->GetRootWindow()->bounds().right(), | 565 EXPECT_NE(window->GetRootWindow()->bounds().right(), |
572 window->GetBoundsInScreen().right()); | 566 window->GetBoundsInScreen().right()); |
573 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, | 567 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, |
574 window->parent()->id()); | 568 window->parent()->id()); |
575 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 569 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
576 | 570 |
577 // Keep dragging it to the right until it docks. The window should now be | 571 // Keep dragging it to the right until its left edge touches the screen edge. |
578 // in the second screen. | 572 // The window should now be in the second screen and not docked. |
579 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin( | 573 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin( |
580 window.get(), | 574 window.get(), |
581 window->bounds().width()/2 + 10, | 575 window->bounds().width()/2 + 10, |
582 0)); | 576 0)); |
583 DragMove(window->GetRootWindow()->GetBoundsInScreen().x() - | 577 DragMove(window->GetRootWindow()->GetBoundsInScreen().x() - |
584 window->GetBoundsInScreen().x(), | 578 window->GetBoundsInScreen().x(), |
585 0); | 579 0); |
586 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 580 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
587 DragEnd(); | 581 DragEnd(); |
588 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), | 582 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), |
589 window->GetBoundsInScreen().x()); | 583 window->GetBoundsInScreen().x()); |
590 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 584 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); |
591 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 585 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
592 } | 586 } |
593 | 587 |
594 // Dock two windows, undock one. | 588 // Dock two windows, undock one. |
595 // Test the docked windows area size and default container resizing. | 589 // Test the docked windows area size and default container resizing. |
596 TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) | 590 TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) |
597 { | 591 { |
598 if (!SupportsHostWindowResize()) | 592 if (!SupportsHostWindowResize()) |
599 return; | 593 return; |
600 | 594 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 EXPECT_EQ(w2->GetRootWindow()->bounds().right() - | 652 EXPECT_EQ(w2->GetRootWindow()->bounds().right() - |
659 (w2->bounds().width()/2 + 20), | 653 (w2->bounds().width()/2 + 20), |
660 w2->GetBoundsInScreen().right()); | 654 w2->GetBoundsInScreen().right()); |
661 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); | 655 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); |
662 // Dock width should be set to remaining single docked window. | 656 // Dock width should be set to remaining single docked window. |
663 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 657 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
664 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); | 658 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); |
665 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); | 659 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); |
666 } | 660 } |
667 | 661 |
668 // Dock one windows. Maximize other testing desktop resizing. | 662 // Dock one of the windows. Maximize other testing desktop resizing. |
669 TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) | 663 TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) |
670 { | 664 { |
671 if (!SupportsHostWindowResize()) | 665 if (!SupportsHostWindowResize()) |
672 return; | 666 return; |
673 | 667 |
674 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 668 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
675 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 669 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
676 // Work area should cover the whole screen. | 670 // Work area should cover the whole screen. |
677 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), | 671 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), |
678 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 672 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
679 | 673 |
680 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 674 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
681 // A window should be attached and snapped to the right edge. | 675 // A window should be attached and snapped to the right edge. |
682 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 676 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
683 w1->GetBoundsInScreen().right()); | 677 w1->GetBoundsInScreen().right()); |
684 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 678 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
685 DockedWindowLayoutManager* manager = | 679 DockedWindowLayoutManager* manager = |
686 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 680 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
687 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); | 681 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); |
688 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); | 682 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); |
689 | 683 |
690 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_RIGHT, | 684 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w2.get(), 25, 5)); |
691 w2.get(), | 685 DragMove(w2->GetRootWindow()->bounds().right() |
692 -(w2->bounds().width()/2 + 20), | 686 -w2->bounds().width() |
693 50); | 687 -(w2->bounds().width()/2 + 20) |
| 688 -w2->bounds().x(), |
| 689 50 - w2->bounds().y()); |
| 690 DragEnd(); |
694 // The first window should be still docked. | 691 // The first window should be still docked. |
695 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 692 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
696 w1->GetBoundsInScreen().right()); | 693 w1->GetBoundsInScreen().right()); |
697 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 694 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
698 | 695 |
699 // The second window should be floating on the desktop. | 696 // The second window should be floating on the desktop. |
700 EXPECT_EQ(w2->GetRootWindow()->bounds().right() - | 697 EXPECT_EQ(w2->GetRootWindow()->bounds().right() - |
701 (w2->bounds().width()/2 + 20), | 698 (w2->bounds().width()/2 + 20), |
702 w2->GetBoundsInScreen().right()); | 699 w2->GetBoundsInScreen().right()); |
703 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); | 700 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); |
(...skipping 27 matching lines...) Expand all Loading... |
731 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); | 728 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); |
732 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, manager->alignment_); | 729 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, manager->alignment_); |
733 EXPECT_EQ(0, manager->docked_width_); | 730 EXPECT_EQ(0, manager->docked_width_); |
734 // The second window should now get resized and take up the whole screen. | 731 // The second window should now get resized and take up the whole screen. |
735 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), | 732 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), |
736 w2->bounds().width()); | 733 w2->bounds().width()); |
737 | 734 |
738 // Dock the first window to the left edge. | 735 // Dock the first window to the left edge. |
739 // Click at an offset from origin to prevent snapping. | 736 // Click at an offset from origin to prevent snapping. |
740 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w1.get(), 10, 0)); | 737 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w1.get(), 10, 0)); |
741 DragMove(-w1->bounds().x(), 0); | 738 // Drag left to get pointer touching the screen edge. |
| 739 DragMove(-w1->bounds().x() - 10, 0); |
742 // Alignment set to "NONE" during the drag of the window when none are docked. | 740 // Alignment set to "NONE" during the drag of the window when none are docked. |
743 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, manager->alignment_); | 741 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, manager->alignment_); |
744 // Release the mouse and the window should be now attached to the edge. | 742 // Release the mouse and the window should be now attached to the edge. |
745 DragEnd(); | 743 DragEnd(); |
746 // Dock should get expanded and desktop should get shrunk. | 744 // Dock should get expanded and desktop should get shrunk. |
747 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 745 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
748 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_); | 746 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_); |
749 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); | 747 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); |
750 // Second window should still be in the desktop. | 748 // Second window should still be in the desktop. |
751 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); | 749 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); |
(...skipping 28 matching lines...) Expand all Loading... |
780 DockedWindowLayoutManager* manager = | 778 DockedWindowLayoutManager* manager = |
781 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 779 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
782 // The first window should be docked. | 780 // The first window should be docked. |
783 EXPECT_EQ(w1->GetRootWindow()->bounds().x(), | 781 EXPECT_EQ(w1->GetRootWindow()->bounds().x(), |
784 w1->GetBoundsInScreen().x()); | 782 w1->GetBoundsInScreen().x()); |
785 // Dock width should be set to that of a single docked window. | 783 // Dock width should be set to that of a single docked window. |
786 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 784 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
787 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_); | 785 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_); |
788 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); | 786 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); |
789 | 787 |
790 // Position second window in the desktop just to the right of the docked w1. | 788 // Position second window in the desktop 20px to the right of the docked w1. |
791 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, | 789 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, |
792 w2.get(), | 790 w2.get(), |
793 w1->bounds().right() + 20, | 791 20 + |
| 792 25 - |
| 793 DockedWindowLayoutManager::kMinDockGap, |
794 50); | 794 50); |
795 // The second window should be floating on the desktop. | 795 // The second window should be floating on the desktop. |
796 EXPECT_EQ(w2->GetRootWindow()->bounds().x() + (w1->bounds().right() + 20), | 796 EXPECT_EQ(w2->GetRootWindow()->bounds().x() + (w1->bounds().right() + 20), |
797 w2->GetBoundsInScreen().x()); | 797 w2->GetBoundsInScreen().x()); |
798 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); | 798 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); |
799 // Dock width should be set to that of a single docked window. | 799 // Dock width should be set to that of a single docked window. |
800 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 800 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
801 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_); | 801 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_); |
802 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); | 802 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); |
803 | 803 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 // w1 is now wider than w2 and the dock should expand and be as wide as w1. | 910 // w1 is now wider than w2 and the dock should expand and be as wide as w1. |
911 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width()); | 911 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width()); |
912 EXPECT_GT(w1->bounds().width(), w2->bounds().width()); | 912 EXPECT_GT(w1->bounds().width(), w2->bounds().width()); |
913 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); | 913 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); |
914 // Desktop work area should shrink. | 914 // Desktop work area should shrink. |
915 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - | 915 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - |
916 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap, | 916 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap, |
917 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 917 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
918 | 918 |
919 // Resize the first window left by more than the dock maximum width. | 919 // Resize the first window left by more than the dock maximum width. |
920 // This should cause the window to overhang and the dock to shrink to w2. | 920 // This should cause the window width to be restricted by maximum dock width. |
921 previous_width = w1->bounds().width(); | 921 previous_width = w1->bounds().width(); |
922 const int kResizeSpan2 = 250; | 922 const int kResizeSpan2 = 250; |
923 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(), | 923 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(), |
924 0, | 924 0, |
925 20, | 925 20, |
926 HTLEFT)); | 926 HTLEFT)); |
927 DragMove(-kResizeSpan2, 0); | 927 DragMove(-kResizeSpan2, 0); |
928 // Alignment set to "RIGHT" during the drag because dock has a window in it. | 928 // Alignment set to "RIGHT" during the drag because dock has a window in it. |
929 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); | 929 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); |
930 // Release the mouse and the window should be attached to the edge. | 930 // Release the mouse and the window should be attached to the edge. |
931 DragEnd(); | 931 DragEnd(); |
932 // Dock should still have both windows in it. | 932 // Dock should still have both windows in it. |
933 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 933 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
934 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 934 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); |
935 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); | 935 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); |
936 // w1 is now wider than the maximum dock width and the dock should shrink to | 936 // w1 is now as wide as the maximum dock width and the dock should get |
937 // the next widest window (w2). | 937 // resized to the maximum width. |
938 EXPECT_EQ(previous_width + kResizeSpan2, w1->bounds().width()); | 938 EXPECT_EQ(DockedWindowLayoutManager::kMaxDockWidth, w1->bounds().width()); |
939 EXPECT_GT(w1->bounds().width(), w2->bounds().width()); | 939 EXPECT_GT(w1->bounds().width(), w2->bounds().width()); |
940 EXPECT_EQ(w2->bounds().width(), manager->docked_width_); | 940 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); |
941 // Desktop work area should shrink. | 941 // Desktop work area should shrink. |
942 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - | 942 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - |
943 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap, | 943 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap, |
944 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 944 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
945 | 945 |
946 // Resize the first window right to get it completely inside the docked area. | 946 // Resize the first window right to get it completely inside the docked area. |
947 previous_width = w1->bounds().width(); | 947 previous_width = w1->bounds().width(); |
948 const int kResizeSpan3 = 100; | 948 const int kResizeSpan3 = 100; |
949 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(), | 949 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(), |
950 0, | 950 0, |
(...skipping 20 matching lines...) Expand all Loading... |
971 // Resize the first window left to be overhang again. | 971 // Resize the first window left to be overhang again. |
972 previous_width = w1->bounds().width(); | 972 previous_width = w1->bounds().width(); |
973 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(), | 973 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(), |
974 0, | 974 0, |
975 20, | 975 20, |
976 HTLEFT)); | 976 HTLEFT)); |
977 DragMove(-kResizeSpan3, 0); | 977 DragMove(-kResizeSpan3, 0); |
978 DragEnd(); | 978 DragEnd(); |
979 EXPECT_EQ(previous_width + kResizeSpan3, w1->bounds().width()); | 979 EXPECT_EQ(previous_width + kResizeSpan3, w1->bounds().width()); |
980 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 980 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
981 // Docked area should be as wide as the second window - the first is too wide. | 981 // Docked area should be as wide as possible (maximum) and same as w1. |
982 EXPECT_EQ(w2->bounds().width(), manager->docked_width_); | 982 EXPECT_EQ(DockedWindowLayoutManager::kMaxDockWidth, manager->docked_width_); |
| 983 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); |
983 | 984 |
984 // Undock the second window. Docked area should shrink to its minimum size. | 985 // Undock the second window. Docked area should shrink to its minimum size. |
985 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get())); | 986 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get())); |
986 // Drag up as well to avoid attaching panels to launcher shelf. | 987 // Drag up as well to avoid attaching panels to launcher shelf. |
987 DragMove(-40, -100); | 988 DragMove(-(400 - 201), -100); |
988 // Alignment set to "RIGHT" since we have another window docked. | 989 // Alignment set to "RIGHT" since we have another window docked. |
989 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); | 990 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); |
990 // Release the mouse and the window should be no longer attached to the edge. | 991 // Release the mouse and the window should be no longer attached to the edge. |
991 DragEnd(); | 992 DragEnd(); |
992 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); | 993 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); |
993 // Dock should get shrunk to minimum size. | 994 // Dock should be as wide as w1 (and same as maximum width). |
994 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); | 995 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); |
995 EXPECT_EQ(manager->kMinDockWidth, manager->docked_width_); | 996 EXPECT_EQ(DockedWindowLayoutManager::kMaxDockWidth, manager->docked_width_); |
| 997 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); |
996 // The first window should be still docked. | 998 // The first window should be still docked. |
997 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 999 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
998 // Desktop work area should be inset. | 1000 // Desktop work area should be inset. |
999 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - | 1001 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - |
1000 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap, | 1002 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap, |
1001 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 1003 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
1002 } | 1004 } |
1003 | 1005 |
1004 TEST_P(DockedWindowResizerTest, DragToShelf) | 1006 TEST_P(DockedWindowResizerTest, DragToShelf) |
1005 { | 1007 { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 } | 1049 } |
1048 } | 1050 } |
1049 | 1051 |
1050 // Tests run twice - on both panels and normal windows | 1052 // Tests run twice - on both panels and normal windows |
1051 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1053 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
1052 DockedWindowResizerTest, | 1054 DockedWindowResizerTest, |
1053 testing::Values(aura::client::WINDOW_TYPE_NORMAL, | 1055 testing::Values(aura::client::WINDOW_TYPE_NORMAL, |
1054 aura::client::WINDOW_TYPE_PANEL)); | 1056 aura::client::WINDOW_TYPE_PANEL)); |
1055 } // namespace internal | 1057 } // namespace internal |
1056 } // namespace ash | 1058 } // namespace ash |
OLD | NEW |