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