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/common/wm/dock/docked_window_resizer.h" | 5 #include "ash/common/wm/dock/docked_window_resizer.h" |
6 | 6 |
7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
9 #include "ash/common/shelf/shelf_model.h" | 9 #include "ash/common/shelf/shelf_model.h" |
10 #include "ash/common/shelf/shelf_types.h" | 10 #include "ash/common/shelf/shelf_types.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 int min_dock_gap() const { return DockedWindowLayoutManager::kMinDockGap; } | 68 int min_dock_gap() const { return DockedWindowLayoutManager::kMinDockGap; } |
69 int max_width() const { return DockedWindowLayoutManager::kMaxDockWidth; } | 69 int max_width() const { return DockedWindowLayoutManager::kMaxDockWidth; } |
70 int docked_width(const DockedWindowLayoutManager* layout_manager) const { | 70 int docked_width(const DockedWindowLayoutManager* layout_manager) const { |
71 return layout_manager->docked_width_; | 71 return layout_manager->docked_width_; |
72 } | 72 } |
73 int docked_alignment(const DockedWindowLayoutManager* layout_manager) const { | 73 int docked_alignment(const DockedWindowLayoutManager* layout_manager) const { |
74 return layout_manager->alignment_; | 74 return layout_manager->alignment_; |
75 } | 75 } |
76 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 76 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
77 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 77 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
78 &delegate_, | 78 &delegate_, window_type_, 0, bounds); |
79 window_type_, | |
80 0, | |
81 bounds); | |
82 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) { | 79 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) { |
83 test::TestShelfDelegate* shelf_delegate = | 80 test::TestShelfDelegate* shelf_delegate = |
84 test::TestShelfDelegate::instance(); | 81 test::TestShelfDelegate::instance(); |
85 shelf_delegate->AddShelfItem(window); | 82 shelf_delegate->AddShelfItem(window); |
86 PanelLayoutManager* manager = | 83 PanelLayoutManager* manager = |
87 PanelLayoutManager::Get(WmWindowAura::Get(window)); | 84 PanelLayoutManager::Get(WmWindowAura::Get(window)); |
88 manager->Relayout(); | 85 manager->Relayout(); |
89 } | 86 } |
90 return window; | 87 return window; |
91 } | 88 } |
(...skipping 28 matching lines...) Expand all Loading... |
120 return CreateWindowResizer(WmWindowAura::Get(window), point_in_parent, | 117 return CreateWindowResizer(WmWindowAura::Get(window), point_in_parent, |
121 window_component, | 118 window_component, |
122 aura::client::WINDOW_MOVE_SOURCE_MOUSE) | 119 aura::client::WINDOW_MOVE_SOURCE_MOUSE) |
123 .release(); | 120 .release(); |
124 } | 121 } |
125 | 122 |
126 void DragStart(aura::Window* window) { | 123 void DragStart(aura::Window* window) { |
127 DragStartAtOffsetFromWindowOrigin(window, 0, 0); | 124 DragStartAtOffsetFromWindowOrigin(window, 0, 0); |
128 } | 125 } |
129 | 126 |
130 void DragStartAtOffsetFromWindowOrigin(aura::Window* window, | 127 void DragStartAtOffsetFromWindowOrigin(aura::Window* window, int dx, int dy) { |
131 int dx, int dy) { | |
132 initial_location_in_parent_ = | 128 initial_location_in_parent_ = |
133 window->bounds().origin() + gfx::Vector2d(dx, dy); | 129 window->bounds().origin() + gfx::Vector2d(dx, dy); |
134 resizer_.reset(CreateSomeWindowResizer(window, | 130 resizer_.reset(CreateSomeWindowResizer(window, initial_location_in_parent_, |
135 initial_location_in_parent_, | |
136 HTCAPTION)); | 131 HTCAPTION)); |
137 ASSERT_TRUE(resizer_.get()); | 132 ASSERT_TRUE(resizer_.get()); |
138 } | 133 } |
139 | 134 |
140 void ResizeStartAtOffsetFromWindowOrigin(aura::Window* window, | 135 void ResizeStartAtOffsetFromWindowOrigin(aura::Window* window, |
141 int dx, int dy, | 136 int dx, |
| 137 int dy, |
142 int window_component) { | 138 int window_component) { |
143 initial_location_in_parent_ = | 139 initial_location_in_parent_ = |
144 window->bounds().origin() + gfx::Vector2d(dx, dy); | 140 window->bounds().origin() + gfx::Vector2d(dx, dy); |
145 resizer_.reset(CreateSomeWindowResizer(window, | 141 resizer_.reset(CreateSomeWindowResizer(window, initial_location_in_parent_, |
146 initial_location_in_parent_, | |
147 window_component)); | 142 window_component)); |
148 ASSERT_TRUE(resizer_.get()); | 143 ASSERT_TRUE(resizer_.get()); |
149 } | 144 } |
150 | 145 |
151 void DragMove(int dx, int dy) { | 146 void DragMove(int dx, int dy) { |
152 resizer_->Drag(initial_location_in_parent_ + gfx::Vector2d(dx, dy), 0); | 147 resizer_->Drag(initial_location_in_parent_ + gfx::Vector2d(dx, dy), 0); |
153 } | 148 } |
154 | 149 |
155 void DragEnd() { | 150 void DragEnd() { |
156 resizer_->CompleteDrag(); | 151 resizer_->CompleteDrag(); |
157 resizer_.reset(); | 152 resizer_.reset(); |
158 } | 153 } |
159 | 154 |
160 void DragRevert() { | 155 void DragRevert() { |
161 resizer_->RevertDrag(); | 156 resizer_->RevertDrag(); |
162 resizer_.reset(); | 157 resizer_.reset(); |
163 } | 158 } |
164 | 159 |
165 // Panels are parented by panel container during drags. | 160 // Panels are parented by panel container during drags. |
166 // All other windows that are tested here are parented by dock container | 161 // All other windows that are tested here are parented by dock container |
167 // during drags. | 162 // during drags. |
168 int CorrectContainerIdDuringDrag() { | 163 int CorrectContainerIdDuringDrag() { |
169 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) | 164 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) |
170 return kShellWindowId_PanelContainer; | 165 return kShellWindowId_PanelContainer; |
171 return kShellWindowId_DockedContainer; | 166 return kShellWindowId_DockedContainer; |
172 } | 167 } |
173 | 168 |
174 // Test dragging the window vertically (to detach if it is a panel) and then | 169 // Test dragging the window vertically (to detach if it is a panel) and then |
175 // horizontally to the edge with an added offset from the edge of |dx|. | 170 // horizontally to the edge with an added offset from the edge of |dx|. |
176 void DragRelativeToEdge(DockedEdge edge, | 171 void DragRelativeToEdge(DockedEdge edge, aura::Window* window, int dx) { |
177 aura::Window* window, | |
178 int dx) { | |
179 DragVerticallyAndRelativeToEdge( | 172 DragVerticallyAndRelativeToEdge( |
180 edge, | 173 edge, window, dx, window_type_ == ui::wm::WINDOW_TYPE_PANEL ? -100 : 20, |
181 window, | 174 25, 5); |
182 dx, | |
183 window_type_ == ui::wm::WINDOW_TYPE_PANEL ? -100 : 20, | |
184 25, | |
185 5); | |
186 } | 175 } |
187 | 176 |
188 void DragToVerticalPositionAndToEdge(DockedEdge edge, | 177 void DragToVerticalPositionAndToEdge(DockedEdge edge, |
189 aura::Window* window, | 178 aura::Window* window, |
190 int y) { | 179 int y) { |
191 DragToVerticalPositionRelativeToEdge(edge, window, 0, y); | 180 DragToVerticalPositionRelativeToEdge(edge, window, 0, y); |
192 } | 181 } |
193 | 182 |
194 void DragToVerticalPositionRelativeToEdge(DockedEdge edge, | 183 void DragToVerticalPositionRelativeToEdge(DockedEdge edge, |
195 aura::Window* window, | 184 aura::Window* window, |
196 int dx, | 185 int dx, |
197 int y) { | 186 int y) { |
198 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 187 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
199 DragVerticallyAndRelativeToEdge(edge, | 188 DragVerticallyAndRelativeToEdge(edge, window, dx, y - initial_bounds.y(), |
200 window, | |
201 dx, y - initial_bounds.y(), | |
202 25, 5); | 189 25, 5); |
203 } | 190 } |
204 | 191 |
205 // Detach if our window is a panel, then drag it vertically by |dy| and | 192 // Detach if our window is a panel, then drag it vertically by |dy| and |
206 // horizontally to the edge with an added offset from the edge of |dx|. | 193 // horizontally to the edge with an added offset from the edge of |dx|. |
207 void DragVerticallyAndRelativeToEdge(DockedEdge edge, | 194 void DragVerticallyAndRelativeToEdge(DockedEdge edge, |
208 aura::Window* window, | 195 aura::Window* window, |
209 int dx, int dy, | 196 int dx, |
210 int grab_x, int grab_y) { | 197 int dy, |
| 198 int grab_x, |
| 199 int grab_y) { |
211 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 200 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
212 // avoid snap by clicking away from the border | 201 // avoid snap by clicking away from the border |
213 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(window, | 202 ASSERT_NO_FATAL_FAILURE( |
214 grab_x, grab_y)); | 203 DragStartAtOffsetFromWindowOrigin(window, grab_x, grab_y)); |
215 | 204 |
216 gfx::Rect work_area = display::Screen::GetScreen() | 205 gfx::Rect work_area = display::Screen::GetScreen() |
217 ->GetDisplayNearestWindow(window) | 206 ->GetDisplayNearestWindow(window) |
218 .work_area(); | 207 .work_area(); |
219 gfx::Point initial_location_in_screen = initial_location_in_parent_; | 208 gfx::Point initial_location_in_screen = initial_location_in_parent_; |
220 ::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen); | 209 ::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen); |
221 // Drag the window left or right to the edge (or almost to it). | 210 // Drag the window left or right to the edge (or almost to it). |
222 if (edge == DOCKED_EDGE_LEFT) | 211 if (edge == DOCKED_EDGE_LEFT) |
223 dx += work_area.x() - initial_location_in_screen.x(); | 212 dx += work_area.x() - initial_location_in_screen.x(); |
224 else if (edge == DOCKED_EDGE_RIGHT) | 213 else if (edge == DOCKED_EDGE_RIGHT) |
225 dx += work_area.right() - 1 - initial_location_in_screen.x(); | 214 dx += work_area.right() - 1 - initial_location_in_screen.x(); |
226 DragMove(dx, dy); | 215 DragMove(dx, dy); |
227 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 216 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
228 // Release the mouse and the panel should be attached to the dock. | 217 // Release the mouse and the panel should be attached to the dock. |
229 DragEnd(); | 218 DragEnd(); |
230 | 219 |
231 // x-coordinate can get adjusted by snapping or sticking. | 220 // x-coordinate can get adjusted by snapping or sticking. |
232 // y-coordinate could be changed by possible automatic layout if docked. | 221 // y-coordinate could be changed by possible automatic layout if docked. |
233 if (window->parent()->id() != kShellWindowId_DockedContainer && | 222 if (window->parent()->id() != kShellWindowId_DockedContainer && |
234 !wm::GetWindowState(window)->HasRestoreBounds()) { | 223 !wm::GetWindowState(window)->HasRestoreBounds()) { |
235 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); | 224 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); |
236 } | 225 } |
237 } | 226 } |
238 | 227 |
239 bool test_panels() const { return window_type_ == ui::wm::WINDOW_TYPE_PANEL; } | 228 bool test_panels() const { return window_type_ == ui::wm::WINDOW_TYPE_PANEL; } |
240 | 229 |
241 aura::test::TestWindowDelegate* delegate() { | 230 aura::test::TestWindowDelegate* delegate() { return &delegate_; } |
242 return &delegate_; | |
243 } | |
244 | 231 |
245 const gfx::Point& initial_location_in_parent() const { | 232 const gfx::Point& initial_location_in_parent() const { |
246 return initial_location_in_parent_; | 233 return initial_location_in_parent_; |
247 } | 234 } |
248 | 235 |
249 private: | 236 private: |
250 std::unique_ptr<WindowResizer> resizer_; | 237 std::unique_ptr<WindowResizer> resizer_; |
251 ShelfModel* model_; | 238 ShelfModel* model_; |
252 ui::wm::WindowType window_type_; | 239 ui::wm::WindowType window_type_; |
253 aura::test::TestWindowDelegate delegate_; | 240 aura::test::TestWindowDelegate delegate_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 if (!SupportsHostWindowResize()) | 282 if (!SupportsHostWindowResize()) |
296 return; | 283 return; |
297 | 284 |
298 std::unique_ptr<aura::Window> window( | 285 std::unique_ptr<aura::Window> window( |
299 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 286 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
300 // Grabbing at 70px ensures that at least 30% of the window is in screen, | 287 // Grabbing at 70px ensures that at least 30% of the window is in screen, |
301 // otherwise the window would be adjusted in | 288 // otherwise the window would be adjusted in |
302 // WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded. | 289 // WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded. |
303 const int kGrabOffsetX = 70; | 290 const int kGrabOffsetX = 70; |
304 const int kUndershootBy = 1; | 291 const int kUndershootBy = 1; |
305 DragVerticallyAndRelativeToEdge(DOCKED_EDGE_RIGHT, | 292 DragVerticallyAndRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), |
306 window.get(), | |
307 -kUndershootBy, test_panels() ? -100 : 20, | 293 -kUndershootBy, test_panels() ? -100 : 20, |
308 kGrabOffsetX, 5); | 294 kGrabOffsetX, 5); |
309 | 295 |
310 // The window right should be past the screen edge but not docked. | 296 // The window right should be past the screen edge but not docked. |
311 // Initial touch point is 70px to the right which helps to find where the edge | 297 // Initial touch point is 70px to the right which helps to find where the edge |
312 // should be. | 298 // should be. |
313 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right() + | 299 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right() + |
314 window->bounds().width() - kGrabOffsetX - kUndershootBy - 1, | 300 window->bounds().width() - kGrabOffsetX - kUndershootBy - 1, |
315 window->GetBoundsInScreen().right()); | 301 window->GetBoundsInScreen().right()); |
316 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 302 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
317 } | 303 } |
318 | 304 |
319 // Verifies a window can be dragged and attached to the dock. | 305 // Verifies a window can be dragged and attached to the dock. |
320 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { | 306 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { |
321 if (!SupportsHostWindowResize()) | 307 if (!SupportsHostWindowResize()) |
322 return; | 308 return; |
323 | 309 |
324 std::unique_ptr<aura::Window> window( | 310 std::unique_ptr<aura::Window> window( |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 398 |
413 // The window should be docked at the right edge. | 399 // The window should be docked at the right edge. |
414 // Its width should shrink to ideal width. | 400 // Its width should shrink to ideal width. |
415 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 401 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
416 window->GetBoundsInScreen().right()); | 402 window->GetBoundsInScreen().right()); |
417 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); | 403 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); |
418 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 404 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
419 | 405 |
420 // Try to detach by dragging left less than kSnapToDockDistance. | 406 // Try to detach by dragging left less than kSnapToDockDistance. |
421 // The window should stay docked. | 407 // The window should stay docked. |
422 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( | 408 ASSERT_NO_FATAL_FAILURE( |
423 window.get(), 10, 0)); | 409 DragStartAtOffsetFromWindowOrigin(window.get(), 10, 0)); |
424 DragMove(-4, -10); | 410 DragMove(-4, -10); |
425 // Release the mouse and the window should be still attached to the dock. | 411 // Release the mouse and the window should be still attached to the dock. |
426 DragEnd(); | 412 DragEnd(); |
427 | 413 |
428 // The window should be still attached to the right edge. | 414 // The window should be still attached to the right edge. |
429 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 415 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
430 window->GetBoundsInScreen().right()); | 416 window->GetBoundsInScreen().right()); |
431 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 417 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
432 | 418 |
433 // Try to detach by dragging left by kSnapToDockDistance or more. | 419 // Try to detach by dragging left by kSnapToDockDistance or more. |
434 // The window should get undocked. | 420 // The window should get undocked. |
435 const int left_edge = window->bounds().x(); | 421 const int left_edge = window->bounds().x(); |
436 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( | 422 ASSERT_NO_FATAL_FAILURE( |
437 window.get(), 10, 0)); | 423 DragStartAtOffsetFromWindowOrigin(window.get(), 10, 0)); |
438 DragMove(-32, -10); | 424 DragMove(-32, -10); |
439 // Release the mouse and the window should be no longer attached to the dock. | 425 // Release the mouse and the window should be no longer attached to the dock. |
440 DragEnd(); | 426 DragEnd(); |
441 | 427 |
442 // The window should be floating on the desktop again and moved to the left. | 428 // The window should be floating on the desktop again and moved to the left. |
443 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); | 429 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); |
444 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 430 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
445 } | 431 } |
446 | 432 |
447 // Dock on the right side, and undock by dragging the right edge of the window | 433 // Dock on the right side, and undock by dragging the right edge of the window |
(...skipping 10 matching lines...) Expand all Loading... |
458 | 444 |
459 // The window should be docked at the right edge. | 445 // The window should be docked at the right edge. |
460 // Its width should shrink to ideal width. | 446 // Its width should shrink to ideal width. |
461 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 447 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
462 window->GetBoundsInScreen().right()); | 448 window->GetBoundsInScreen().right()); |
463 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); | 449 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); |
464 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 450 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
465 | 451 |
466 // Try to detach by dragging left less than kSnapToDockDistance. | 452 // Try to detach by dragging left less than kSnapToDockDistance. |
467 // The window should stay docked. | 453 // The window should stay docked. |
468 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( | 454 ASSERT_NO_FATAL_FAILURE( |
469 window.get(), ideal_width() - 10, 0)); | 455 DragStartAtOffsetFromWindowOrigin(window.get(), ideal_width() - 10, 0)); |
470 DragMove(-4, -10); | 456 DragMove(-4, -10); |
471 // Release the mouse and the window should be still attached to the dock. | 457 // Release the mouse and the window should be still attached to the dock. |
472 DragEnd(); | 458 DragEnd(); |
473 | 459 |
474 // The window should be still attached to the right edge. | 460 // The window should be still attached to the right edge. |
475 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 461 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
476 window->GetBoundsInScreen().right()); | 462 window->GetBoundsInScreen().right()); |
477 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 463 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
478 | 464 |
479 // Try to detach by dragging left by kSnapToDockDistance or more. | 465 // Try to detach by dragging left by kSnapToDockDistance or more. |
480 // The window should get undocked. | 466 // The window should get undocked. |
481 const int left_edge = window->bounds().x(); | 467 const int left_edge = window->bounds().x(); |
482 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( | 468 ASSERT_NO_FATAL_FAILURE( |
483 window.get(), ideal_width() - 10, 0)); | 469 DragStartAtOffsetFromWindowOrigin(window.get(), ideal_width() - 10, 0)); |
484 DragMove(-32, -10); | 470 DragMove(-32, -10); |
485 // Release the mouse and the window should be no longer attached to the dock. | 471 // Release the mouse and the window should be no longer attached to the dock. |
486 DragEnd(); | 472 DragEnd(); |
487 | 473 |
488 // The window should be floating on the desktop again and moved to the left. | 474 // The window should be floating on the desktop again and moved to the left. |
489 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); | 475 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); |
490 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 476 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
491 } | 477 } |
492 | 478 |
493 // Minimize a docked window, then restore it and check that it is still docked. | 479 // Minimize a docked window, then restore it and check that it is still docked. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 gfx::Rect initial_bounds(w2->bounds()); | 623 gfx::Rect initial_bounds(w2->bounds()); |
638 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); | 624 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); |
639 | 625 |
640 // The first window should be docked at the right edge. | 626 // The first window should be docked at the right edge. |
641 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 627 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
642 w1->GetBoundsInScreen().right()); | 628 w1->GetBoundsInScreen().right()); |
643 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 629 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
644 | 630 |
645 // The second window should be near the left edge but not snapped. | 631 // The second window should be near the left edge but not snapped. |
646 // Normal window will get side-maximized while panels will not. | 632 // Normal window will get side-maximized while panels will not. |
647 int expected_x = test_panels() ? | 633 int expected_x = test_panels() |
648 (initial_bounds.x() - initial_location_in_parent().x()) : 0; | 634 ? (initial_bounds.x() - initial_location_in_parent().x()) |
| 635 : 0; |
649 EXPECT_EQ(expected_x, w2->GetBoundsInScreen().x()); | 636 EXPECT_EQ(expected_x, w2->GetBoundsInScreen().x()); |
650 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 637 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
651 } | 638 } |
652 | 639 |
653 // Tests that reverting a drag restores docked state if a window was docked. | 640 // Tests that reverting a drag restores docked state if a window was docked. |
654 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { | 641 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { |
655 if (!SupportsHostWindowResize()) | 642 if (!SupportsHostWindowResize()) |
656 return; | 643 return; |
657 | 644 |
658 std::unique_ptr<aura::Window> window( | 645 std::unique_ptr<aura::Window> window( |
(...skipping 30 matching lines...) Expand all Loading... |
689 // Drag the window out but revert the drag | 676 // Drag the window out but revert the drag |
690 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 677 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
691 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); | 678 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); |
692 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 679 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
693 DragRevert(); | 680 DragRevert(); |
694 EXPECT_EQ(previous_container_id, window->parent()->id()); | 681 EXPECT_EQ(previous_container_id, window->parent()->id()); |
695 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); | 682 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); |
696 | 683 |
697 // Drag a window to the left so that it overlaps the screen edge. | 684 // Drag a window to the left so that it overlaps the screen edge. |
698 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( | 685 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( |
699 window.get(), | 686 window.get(), window->bounds().width() / 2 + 10, 0)); |
700 window->bounds().width()/2 + 10, | |
701 0)); | |
702 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); | 687 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); |
703 DragEnd(); | 688 DragEnd(); |
704 // The window now overlaps the left screen edge but is not docked. | 689 // The window now overlaps the left screen edge but is not docked. |
705 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 690 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
706 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); | 691 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); |
707 EXPECT_LT(window->bounds().x(), 0); | 692 EXPECT_LT(window->bounds().x(), 0); |
708 EXPECT_GT(window->bounds().right(), 0); | 693 EXPECT_GT(window->bounds().right(), 0); |
709 | 694 |
710 // Drag the window further left and revert the drag. | 695 // Drag the window further left and revert the drag. |
711 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( | 696 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( |
712 window.get(), | 697 window.get(), window->bounds().width() / 2 + 10, 0)); |
713 window->bounds().width()/2 + 10, | |
714 0)); | |
715 DragMove(-10, 10); | 698 DragMove(-10, 10); |
716 DragRevert(); | 699 DragRevert(); |
717 // The window should be in default container and not docked. | 700 // The window should be in default container and not docked. |
718 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 701 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
719 // Docked area alignment should be cleared. | 702 // Docked area alignment should be cleared. |
720 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); | 703 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); |
721 } | 704 } |
722 | 705 |
723 // Move a docked window to the second display | 706 // Move a docked window to the second display |
724 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { | 707 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { |
(...skipping 22 matching lines...) Expand all Loading... |
747 DragEnd(); | 730 DragEnd(); |
748 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 731 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
749 window->GetBoundsInScreen().right()); | 732 window->GetBoundsInScreen().right()); |
750 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 733 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
751 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 734 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
752 | 735 |
753 // Undock and move to the right - enough to get the mouse pointer past the | 736 // Undock and move to the right - enough to get the mouse pointer past the |
754 // edge of the screen and into the second screen. The window should now be | 737 // edge of the screen and into the second screen. The window should now be |
755 // in the second screen and not docked. | 738 // in the second screen and not docked. |
756 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( | 739 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( |
757 window.get(), | 740 window.get(), window->bounds().width() / 2 + 10, 0)); |
758 window->bounds().width()/2 + 10, | 741 DragMove(window->bounds().width() / 2 - 5, 0); |
759 0)); | |
760 DragMove(window->bounds().width()/2 - 5, 0); | |
761 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 742 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
762 DragEnd(); | 743 DragEnd(); |
763 EXPECT_NE(window->GetRootWindow()->GetBoundsInScreen().right(), | 744 EXPECT_NE(window->GetRootWindow()->GetBoundsInScreen().right(), |
764 window->GetBoundsInScreen().right()); | 745 window->GetBoundsInScreen().right()); |
765 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 746 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
766 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 747 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
767 | 748 |
768 // Keep dragging it to the right until its left edge touches the screen edge. | 749 // Keep dragging it to the right until its left edge touches the screen edge. |
769 // The window should now be in the second screen and not docked. | 750 // The window should now be in the second screen and not docked. |
770 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( | 751 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( |
771 window.get(), | 752 window.get(), window->bounds().width() / 2 + 10, 0)); |
772 window->bounds().width()/2 + 10, | |
773 0)); | |
774 DragMove(window->GetRootWindow()->GetBoundsInScreen().x() - | 753 DragMove(window->GetRootWindow()->GetBoundsInScreen().x() - |
775 window->GetBoundsInScreen().x(), | 754 window->GetBoundsInScreen().x(), |
776 0); | 755 0); |
777 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 756 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
778 DragEnd(); | 757 DragEnd(); |
779 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), | 758 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), |
780 window->GetBoundsInScreen().x()); | 759 window->GetBoundsInScreen().x()); |
781 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 760 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
782 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 761 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
783 } | 762 } |
784 | 763 |
785 // Dock two windows, undock one. | 764 // Dock two windows, undock one. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 810 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
832 | 811 |
833 // The second window should be still docked. | 812 // The second window should be still docked. |
834 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), | 813 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), |
835 w2->GetBoundsInScreen().right()); | 814 w2->GetBoundsInScreen().right()); |
836 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 815 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
837 | 816 |
838 // Detach by dragging left more (should get undocked). | 817 // Detach by dragging left more (should get undocked). |
839 const int left_edge = w2->bounds().x(); | 818 const int left_edge = w2->bounds().x(); |
840 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( | 819 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( |
841 w2.get(), | 820 w2.get(), w2->bounds().width() / 2 + 10, 0)); |
842 w2->bounds().width()/2 + 10, | |
843 0)); | |
844 // Drag up as well to avoid attaching panels to launcher shelf. | 821 // Drag up as well to avoid attaching panels to launcher shelf. |
845 const int drag_x = -(w2->bounds().width()/2 + 20); | 822 const int drag_x = -(w2->bounds().width() / 2 + 20); |
846 DragMove(drag_x, -100); | 823 DragMove(drag_x, -100); |
847 // Release the mouse and the window should be no longer attached to the edge. | 824 // Release the mouse and the window should be no longer attached to the edge. |
848 DragEnd(); | 825 DragEnd(); |
849 | 826 |
850 // The second window should be floating on the desktop again. | 827 // The second window should be floating on the desktop again. |
851 EXPECT_EQ(left_edge + drag_x, w2->bounds().x()); | 828 EXPECT_EQ(left_edge + drag_x, w2->bounds().x()); |
852 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 829 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
853 // Dock width should be set to remaining single docked window. | 830 // Dock width should be set to remaining single docked window. |
854 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 831 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
855 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 832 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
(...skipping 15 matching lines...) Expand all Loading... |
871 // A window should be docked at the right edge. | 848 // A window should be docked at the right edge. |
872 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 849 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
873 w1->GetBoundsInScreen().right()); | 850 w1->GetBoundsInScreen().right()); |
874 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 851 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
875 DockedWindowLayoutManager* manager = | 852 DockedWindowLayoutManager* manager = |
876 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 853 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
877 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 854 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
878 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 855 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
879 | 856 |
880 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5)); | 857 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5)); |
881 DragMove(w2->GetRootWindow()->bounds().width() | 858 DragMove(w2->GetRootWindow()->bounds().width() - w2->bounds().width() - |
882 -w2->bounds().width() | 859 (w2->bounds().width() / 2 + 20) - w2->bounds().x(), |
883 -(w2->bounds().width()/2 + 20) | |
884 -w2->bounds().x(), | |
885 50 - w2->bounds().y()); | 860 50 - w2->bounds().y()); |
886 DragEnd(); | 861 DragEnd(); |
887 // The first window should be still docked. | 862 // The first window should be still docked. |
888 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 863 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
889 w1->GetBoundsInScreen().right()); | 864 w1->GetBoundsInScreen().right()); |
890 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 865 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
891 | 866 |
892 // The second window should be floating on the desktop. | 867 // The second window should be floating on the desktop. |
893 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right() - | 868 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right() - |
894 (w2->bounds().width()/2 + 20), | 869 (w2->bounds().width() / 2 + 20), |
895 w2->GetBoundsInScreen().right()); | 870 w2->GetBoundsInScreen().right()); |
896 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 871 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
897 // Dock width should be set to remaining single docked window. | 872 // Dock width should be set to remaining single docked window. |
898 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 873 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
899 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 874 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
900 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 875 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
901 // Desktop work area should now shrink. | 876 // Desktop work area should now shrink. |
902 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - | 877 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - |
903 docked_width(manager) - min_dock_gap(), | 878 docked_width(manager) - min_dock_gap(), |
904 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 879 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
905 | 880 |
906 // Maximize the second window - Maximized area should be shrunk. | 881 // Maximize the second window - Maximized area should be shrunk. |
907 const gfx::Rect restored_bounds = w2->bounds(); | 882 const gfx::Rect restored_bounds = w2->bounds(); |
908 wm::WindowState* w2_state = wm::GetWindowState(w2.get()); | 883 wm::WindowState* w2_state = wm::GetWindowState(w2.get()); |
909 w2_state->Maximize(); | 884 w2_state->Maximize(); |
910 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - | 885 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - |
911 docked_width(manager) - min_dock_gap(), | 886 docked_width(manager) - min_dock_gap(), |
912 w2->bounds().width()); | 887 w2->bounds().width()); |
913 | 888 |
914 // Detach the first window (this should require very little drag). | 889 // Detach the first window (this should require very little drag). |
915 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); | 890 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); |
916 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 891 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
917 DragMove(-35, 10); | 892 DragMove(-35, 10); |
918 // Alignment is set to "NONE" when drag starts. | 893 // Alignment is set to "NONE" when drag starts. |
919 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); | 894 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); |
920 // Release the mouse and the window should be no longer attached to the edge. | 895 // Release the mouse and the window should be no longer attached to the edge. |
921 DragEnd(); | 896 DragEnd(); |
(...skipping 17 matching lines...) Expand all Loading... |
939 // Release the mouse and the window should be now attached to the edge. | 914 // Release the mouse and the window should be now attached to the edge. |
940 DragEnd(); | 915 DragEnd(); |
941 // Dock should get expanded and desktop should get shrunk. | 916 // Dock should get expanded and desktop should get shrunk. |
942 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 917 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
943 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); | 918 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); |
944 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 919 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
945 // Second window should still be in the desktop. | 920 // Second window should still be in the desktop. |
946 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 921 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
947 // Maximized window should be shrunk. | 922 // Maximized window should be shrunk. |
948 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - | 923 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - |
949 docked_width(manager) - min_dock_gap(), | 924 docked_width(manager) - min_dock_gap(), |
950 w2->bounds().width()); | 925 w2->bounds().width()); |
951 | 926 |
952 // Unmaximize the second window. | 927 // Unmaximize the second window. |
953 w2_state->Restore(); | 928 w2_state->Restore(); |
954 // Its bounds should get restored. | 929 // Its bounds should get restored. |
955 EXPECT_EQ(restored_bounds, w2->bounds()); | 930 EXPECT_EQ(restored_bounds, w2->bounds()); |
956 } | 931 } |
957 | 932 |
958 // Dock one window. Test the sticky behavior near screen or desktop edge. | 933 // Dock one window. Test the sticky behavior near screen or desktop edge. |
959 TEST_P(DockedWindowResizerTest, AttachOneTestSticky) { | 934 TEST_P(DockedWindowResizerTest, AttachOneTestSticky) { |
(...skipping 15 matching lines...) Expand all Loading... |
975 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 950 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
976 // The first window should be docked. | 951 // The first window should be docked. |
977 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), | 952 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), |
978 w1->GetBoundsInScreen().x()); | 953 w1->GetBoundsInScreen().x()); |
979 // Dock width should be set to that of a single docked window. | 954 // Dock width should be set to that of a single docked window. |
980 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 955 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
981 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); | 956 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); |
982 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 957 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
983 | 958 |
984 // Position second window in the desktop 20px to the right of the docked w1. | 959 // Position second window in the desktop 20px to the right of the docked w1. |
985 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, | 960 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, w2.get(), |
986 w2.get(), | 961 20 + 25 - min_dock_gap(), 50); |
987 20 + 25 - | |
988 min_dock_gap(), | |
989 50); | |
990 // The second window should be floating on the desktop. | 962 // The second window should be floating on the desktop. |
991 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().x() + | 963 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().x() + |
992 (w1->bounds().right() + 20), | 964 (w1->bounds().right() + 20), |
993 w2->GetBoundsInScreen().x()); | 965 w2->GetBoundsInScreen().x()); |
994 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 966 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
995 // Dock width should be set to that of a single docked window. | 967 // Dock width should be set to that of a single docked window. |
996 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 968 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
997 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); | 969 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); |
998 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 970 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
999 | 971 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 DragEnd(); | 1013 DragEnd(); |
1042 // Both windows are docked now. | 1014 // Both windows are docked now. |
1043 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1015 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1044 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1016 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1045 // Dock should get expanded and desktop should get shrunk. | 1017 // Dock should get expanded and desktop should get shrunk. |
1046 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); | 1018 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); |
1047 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), | 1019 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), |
1048 docked_width(manager)); | 1020 docked_width(manager)); |
1049 // Desktop work area should now shrink by dock width. | 1021 // Desktop work area should now shrink by dock width. |
1050 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - | 1022 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - |
1051 docked_width(manager) - min_dock_gap(), | 1023 docked_width(manager) - min_dock_gap(), |
1052 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 1024 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
1053 } | 1025 } |
1054 | 1026 |
1055 // Dock two windows, resize one. | 1027 // Dock two windows, resize one. |
1056 // Test the docked windows area size and remaining desktop resizing. | 1028 // Test the docked windows area size and remaining desktop resizing. |
1057 TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { | 1029 TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { |
1058 if (!SupportsHostWindowResize()) | 1030 if (!SupportsHostWindowResize()) |
1059 return; | 1031 return; |
1060 | 1032 |
1061 // Wider display to start since panels are limited to half the display width. | 1033 // Wider display to start since panels are limited to half the display width. |
(...skipping 20 matching lines...) Expand all Loading... |
1082 w2->GetBoundsInScreen().right()); | 1054 w2->GetBoundsInScreen().right()); |
1083 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1055 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1084 // Dock width should be set to a wider window. | 1056 // Dock width should be set to a wider window. |
1085 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1057 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1086 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), | 1058 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), |
1087 docked_width(manager)); | 1059 docked_width(manager)); |
1088 | 1060 |
1089 // Resize the first window left by a bit and test that the dock expands. | 1061 // Resize the first window left by a bit and test that the dock expands. |
1090 int previous_width = w1->bounds().width(); | 1062 int previous_width = w1->bounds().width(); |
1091 const int kResizeSpan1 = 30; | 1063 const int kResizeSpan1 = 30; |
1092 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), | 1064 ASSERT_NO_FATAL_FAILURE( |
1093 0, 20, | 1065 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); |
1094 HTLEFT)); | |
1095 DragMove(-kResizeSpan1, 0); | 1066 DragMove(-kResizeSpan1, 0); |
1096 // Alignment set to "RIGHT" during the drag because dock has a window in it. | 1067 // Alignment set to "RIGHT" during the drag because dock has a window in it. |
1097 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1068 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1098 // Release the mouse and the window should be attached to the edge. | 1069 // Release the mouse and the window should be attached to the edge. |
1099 DragEnd(); | 1070 DragEnd(); |
1100 // Dock should still have both windows in it. | 1071 // Dock should still have both windows in it. |
1101 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1072 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1102 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1073 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1103 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1074 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1104 // w1 is now wider than before. The dock should expand and be as wide as w1. | 1075 // w1 is now wider than before. The dock should expand and be as wide as w1. |
1105 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width()); | 1076 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width()); |
1106 // Both windows should get resized since they both don't have min/max size. | 1077 // Both windows should get resized since they both don't have min/max size. |
1107 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); | 1078 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); |
1108 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1079 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1109 // Desktop work area should shrink. | 1080 // Desktop work area should shrink. |
1110 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - | 1081 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - |
1111 docked_width(manager) - min_dock_gap(), | 1082 docked_width(manager) - min_dock_gap(), |
1112 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 1083 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
1113 | 1084 |
1114 // Resize the first window left by more than the dock maximum width. | 1085 // Resize the first window left by more than the dock maximum width. |
1115 // This should cause the window width to be restricted by maximum dock width. | 1086 // This should cause the window width to be restricted by maximum dock width. |
1116 previous_width = w1->bounds().width(); | 1087 previous_width = w1->bounds().width(); |
1117 const int kResizeSpan2 = 250; | 1088 const int kResizeSpan2 = 250; |
1118 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), | 1089 ASSERT_NO_FATAL_FAILURE( |
1119 0, 20, | 1090 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); |
1120 HTLEFT)); | |
1121 DragMove(-kResizeSpan2, 0); | 1091 DragMove(-kResizeSpan2, 0); |
1122 // Alignment set to "RIGHT" during the drag because dock has a window in it. | 1092 // Alignment set to "RIGHT" during the drag because dock has a window in it. |
1123 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1093 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1124 // Release the mouse and the window should be attached to the edge. | 1094 // Release the mouse and the window should be attached to the edge. |
1125 DragEnd(); | 1095 DragEnd(); |
1126 // Dock should still have both windows in it. | 1096 // Dock should still have both windows in it. |
1127 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1097 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1128 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1098 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1129 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1099 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1130 // w1 is now as wide as the maximum dock width and the dock should get | 1100 // w1 is now as wide as the maximum dock width and the dock should get |
1131 // resized to the maximum width. | 1101 // resized to the maximum width. |
1132 EXPECT_EQ(max_width(), w1->bounds().width()); | 1102 EXPECT_EQ(max_width(), w1->bounds().width()); |
1133 // Both windows should get resized since they both don't have min/max size. | 1103 // Both windows should get resized since they both don't have min/max size. |
1134 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); | 1104 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); |
1135 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1105 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1136 // Desktop work area should shrink. | 1106 // Desktop work area should shrink. |
1137 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - | 1107 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - |
1138 docked_width(manager) - min_dock_gap(), | 1108 docked_width(manager) - min_dock_gap(), |
1139 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 1109 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
1140 | 1110 |
1141 // Resize the first window right to get it completely inside the docked area. | 1111 // Resize the first window right to get it completely inside the docked area. |
1142 previous_width = w1->bounds().width(); | 1112 previous_width = w1->bounds().width(); |
1143 const int kResizeSpan3 = 100; | 1113 const int kResizeSpan3 = 100; |
1144 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), | 1114 ASSERT_NO_FATAL_FAILURE( |
1145 0, 20, | 1115 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); |
1146 HTLEFT)); | |
1147 DragMove(kResizeSpan3, 0); | 1116 DragMove(kResizeSpan3, 0); |
1148 // Alignment set to "RIGHT" during the drag because dock has a window in it. | 1117 // Alignment set to "RIGHT" during the drag because dock has a window in it. |
1149 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1118 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1150 // Release the mouse and the window should be docked. | 1119 // Release the mouse and the window should be docked. |
1151 DragEnd(); | 1120 DragEnd(); |
1152 // Dock should still have both windows in it. | 1121 // Dock should still have both windows in it. |
1153 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1122 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1154 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1123 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1155 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1124 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1156 // w1 should be narrower than before by the length of the drag. | 1125 // w1 should be narrower than before by the length of the drag. |
1157 EXPECT_EQ(previous_width - kResizeSpan3, w1->bounds().width()); | 1126 EXPECT_EQ(previous_width - kResizeSpan3, w1->bounds().width()); |
1158 // Both windows should get resized since they both don't have min/max size. | 1127 // Both windows should get resized since they both don't have min/max size. |
1159 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); | 1128 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); |
1160 // The dock should be as wide as w1 or w2. | 1129 // The dock should be as wide as w1 or w2. |
1161 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1130 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1162 // Desktop work area should shrink. | 1131 // Desktop work area should shrink. |
1163 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - | 1132 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - |
1164 docked_width(manager) - min_dock_gap(), | 1133 docked_width(manager) - min_dock_gap(), |
1165 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 1134 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
1166 | 1135 |
1167 // Resize the first window left to be overhang again. | 1136 // Resize the first window left to be overhang again. |
1168 previous_width = w1->bounds().width(); | 1137 previous_width = w1->bounds().width(); |
1169 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), | 1138 ASSERT_NO_FATAL_FAILURE( |
1170 0, 20, | 1139 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); |
1171 HTLEFT)); | |
1172 DragMove(-kResizeSpan3, 0); | 1140 DragMove(-kResizeSpan3, 0); |
1173 DragEnd(); | 1141 DragEnd(); |
1174 EXPECT_EQ(previous_width + kResizeSpan3, w1->bounds().width()); | 1142 EXPECT_EQ(previous_width + kResizeSpan3, w1->bounds().width()); |
1175 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1143 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1176 // Docked area should be as wide as possible (maximum) and same as w1. | 1144 // Docked area should be as wide as possible (maximum) and same as w1. |
1177 EXPECT_EQ(max_width(), docked_width(manager)); | 1145 EXPECT_EQ(max_width(), docked_width(manager)); |
1178 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1146 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1179 | 1147 |
1180 // Undock the first window. Docked area should shrink to its ideal size. | 1148 // Undock the first window. Docked area should shrink to its ideal size. |
1181 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); | 1149 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); |
1182 // Drag up as well to avoid attaching panels to launcher shelf. | 1150 // Drag up as well to avoid attaching panels to launcher shelf. |
1183 DragMove(-(400 - 210), -100); | 1151 DragMove(-(400 - 210), -100); |
1184 // Alignment set to "RIGHT" since we have another window docked. | 1152 // Alignment set to "RIGHT" since we have another window docked. |
1185 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1153 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1186 // Release the mouse and the window should be no longer attached to the edge. | 1154 // Release the mouse and the window should be no longer attached to the edge. |
1187 DragEnd(); | 1155 DragEnd(); |
1188 EXPECT_EQ(kShellWindowId_DefaultContainer, w1->parent()->id()); | 1156 EXPECT_EQ(kShellWindowId_DefaultContainer, w1->parent()->id()); |
1189 // Dock should be as wide as w2 (and same as ideal width). | 1157 // Dock should be as wide as w2 (and same as ideal width). |
1190 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1158 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1191 EXPECT_EQ(ideal_width(), docked_width(manager)); | 1159 EXPECT_EQ(ideal_width(), docked_width(manager)); |
1192 EXPECT_EQ(w2->bounds().width(), docked_width(manager)); | 1160 EXPECT_EQ(w2->bounds().width(), docked_width(manager)); |
1193 // The second window should be still docked. | 1161 // The second window should be still docked. |
1194 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1162 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1195 // Desktop work area should be inset. | 1163 // Desktop work area should be inset. |
1196 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width() - | 1164 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width() - |
1197 docked_width(manager) - min_dock_gap(), | 1165 docked_width(manager) - min_dock_gap(), |
1198 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); | 1166 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); |
1199 } | 1167 } |
1200 | 1168 |
1201 // Dock a window, resize it and test that undocking it restores the pre-docked | 1169 // Dock a window, resize it and test that undocking it restores the pre-docked |
1202 // size. | 1170 // size. |
1203 TEST_P(DockedWindowResizerTest, ResizingKeepsSize) { | 1171 TEST_P(DockedWindowResizerTest, ResizingKeepsSize) { |
1204 if (!SupportsHostWindowResize()) | 1172 if (!SupportsHostWindowResize()) |
1205 return; | 1173 return; |
1206 | 1174 |
1207 // Wider display to start since panels are limited to half the display width. | 1175 // Wider display to start since panels are limited to half the display width. |
1208 UpdateDisplay("1000x600"); | 1176 UpdateDisplay("1000x600"); |
1209 const gfx::Size original_size(201, 201); | 1177 const gfx::Size original_size(201, 201); |
1210 std::unique_ptr<aura::Window> w1( | 1178 std::unique_ptr<aura::Window> w1( |
1211 CreateTestWindow(gfx::Rect(gfx::Point(), original_size))); | 1179 CreateTestWindow(gfx::Rect(gfx::Point(), original_size))); |
1212 | 1180 |
1213 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1181 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1214 // Window should be docked at the right edge. | 1182 // Window should be docked at the right edge. |
1215 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1183 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1216 w1->GetBoundsInScreen().right()); | 1184 w1->GetBoundsInScreen().right()); |
1217 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1185 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1218 DockedWindowLayoutManager* manager = | 1186 DockedWindowLayoutManager* manager = |
1219 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 1187 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
1220 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1188 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1221 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1189 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1222 | 1190 |
1223 // Resize the window left by a bit and test that the dock expands. | 1191 // Resize the window left by a bit and test that the dock expands. |
1224 int previous_width = w1->bounds().width(); | 1192 int previous_width = w1->bounds().width(); |
1225 const int kResizeSpan1 = 30; | 1193 const int kResizeSpan1 = 30; |
1226 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), | 1194 ASSERT_NO_FATAL_FAILURE( |
1227 0, 20, | 1195 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); |
1228 HTLEFT)); | |
1229 DragMove(-kResizeSpan1, 0); | 1196 DragMove(-kResizeSpan1, 0); |
1230 // Alignment stays "RIGHT" during the drag because the only docked window | 1197 // Alignment stays "RIGHT" during the drag because the only docked window |
1231 // is being resized. | 1198 // is being resized. |
1232 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1199 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1233 // Release the mouse and the window should be attached to the edge. | 1200 // Release the mouse and the window should be attached to the edge. |
1234 DragEnd(); | 1201 DragEnd(); |
1235 // The window should get docked. | 1202 // The window should get docked. |
1236 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1203 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1237 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1204 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1238 // w1 is now wider and the dock should expand to be as wide as w1. | 1205 // w1 is now wider and the dock should expand to be as wide as w1. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 w1->GetBoundsInScreen().right()); | 1237 w1->GetBoundsInScreen().right()); |
1271 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1238 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1272 DockedWindowLayoutManager* manager = | 1239 DockedWindowLayoutManager* manager = |
1273 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 1240 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
1274 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1241 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1275 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1242 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1276 | 1243 |
1277 // Resize the window left by a bit and test that the dock expands. | 1244 // Resize the window left by a bit and test that the dock expands. |
1278 int previous_width = w1->bounds().width(); | 1245 int previous_width = w1->bounds().width(); |
1279 const int kResizeSpan1 = 30; | 1246 const int kResizeSpan1 = 30; |
1280 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin( | 1247 ASSERT_NO_FATAL_FAILURE( |
1281 w1.get(), 0, 20, HTLEFT)); | 1248 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); |
1282 DragMove(-kResizeSpan1, 0); | 1249 DragMove(-kResizeSpan1, 0); |
1283 // Normally alignment would be reset to "NONE" during the drag when there is | 1250 // Normally alignment would be reset to "NONE" during the drag when there is |
1284 // only a single window docked and it is being dragged. However because that | 1251 // only a single window docked and it is being dragged. However because that |
1285 // window is being resized rather than moved the alignment is not changed. | 1252 // window is being resized rather than moved the alignment is not changed. |
1286 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1253 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1287 // Release the mouse and the window should be attached to the edge. | 1254 // Release the mouse and the window should be attached to the edge. |
1288 DragEnd(); | 1255 DragEnd(); |
1289 // The window should stay docked. | 1256 // The window should stay docked. |
1290 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1257 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1291 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1258 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1297 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1331 // Dock width should be set to ideal width. | 1298 // Dock width should be set to ideal width. |
1332 DockedWindowLayoutManager* manager = | 1299 DockedWindowLayoutManager* manager = |
1333 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 1300 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
1334 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1301 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1335 EXPECT_EQ(ideal_width(), docked_width(manager)); | 1302 EXPECT_EQ(ideal_width(), docked_width(manager)); |
1336 | 1303 |
1337 // Resize the first window left by a bit and test that the dock expands. | 1304 // Resize the first window left by a bit and test that the dock expands. |
1338 int previous_width = w1->bounds().width(); | 1305 int previous_width = w1->bounds().width(); |
1339 const int kResizeSpan1 = 30; | 1306 const int kResizeSpan1 = 30; |
1340 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), | 1307 ASSERT_NO_FATAL_FAILURE( |
1341 0, 20, | 1308 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); |
1342 HTLEFT)); | |
1343 DragMove(-kResizeSpan1, 0); | 1309 DragMove(-kResizeSpan1, 0); |
1344 DragEnd(); | 1310 DragEnd(); |
1345 // w1 is now wider than before. | 1311 // w1 is now wider than before. |
1346 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width()); | 1312 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width()); |
1347 // Both windows should get resized since they both don't have min/max size. | 1313 // Both windows should get resized since they both don't have min/max size. |
1348 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); | 1314 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); |
1349 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1315 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1350 | 1316 |
1351 // Resize the second window left by a bit more and test that the dock expands. | 1317 // Resize the second window left by a bit more and test that the dock expands. |
1352 previous_width = w2->bounds().width(); | 1318 previous_width = w2->bounds().width(); |
1353 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w2.get(), | 1319 ASSERT_NO_FATAL_FAILURE( |
1354 0, 20, | 1320 ResizeStartAtOffsetFromWindowOrigin(w2.get(), 0, 20, HTLEFT)); |
1355 HTLEFT)); | |
1356 DragMove(-kResizeSpan1, 0); | 1321 DragMove(-kResizeSpan1, 0); |
1357 DragEnd(); | 1322 DragEnd(); |
1358 // w2 should get wider since it was resized by a user. | 1323 // w2 should get wider since it was resized by a user. |
1359 EXPECT_EQ(previous_width + kResizeSpan1, w2->bounds().width()); | 1324 EXPECT_EQ(previous_width + kResizeSpan1, w2->bounds().width()); |
1360 // w1 should stay as wide as w2 since both were flush with the dock edge. | 1325 // w1 should stay as wide as w2 since both were flush with the dock edge. |
1361 EXPECT_EQ(w2->bounds().width(), w1->bounds().width()); | 1326 EXPECT_EQ(w2->bounds().width(), w1->bounds().width()); |
1362 EXPECT_EQ(w2->bounds().width(), docked_width(manager)); | 1327 EXPECT_EQ(w2->bounds().width(), docked_width(manager)); |
1363 | 1328 |
1364 // Undock w2 and then dock it back. | 1329 // Undock w2 and then dock it back. |
1365 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_RIGHT, w2.get(), -400, 100); | 1330 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_RIGHT, w2.get(), -400, 100); |
1366 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 1331 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
1367 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); | 1332 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
1368 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1333 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1369 // w2 should become same width as w1. | 1334 // w2 should become same width as w1. |
1370 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); | 1335 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); |
1371 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1336 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1372 | 1337 |
1373 // Make w1 even wider. | 1338 // Make w1 even wider. |
1374 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), | 1339 ASSERT_NO_FATAL_FAILURE( |
1375 0, 20, | 1340 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); |
1376 HTLEFT)); | |
1377 DragMove(-kResizeSpan1, 0); | 1341 DragMove(-kResizeSpan1, 0); |
1378 DragEnd(); | 1342 DragEnd(); |
1379 // Making w1 wider should make both windows wider since w2 no longer remembers | 1343 // Making w1 wider should make both windows wider since w2 no longer remembers |
1380 // user width. | 1344 // user width. |
1381 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); | 1345 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); |
1382 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1346 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1383 } | 1347 } |
1384 | 1348 |
1385 // Tests that dragging a window down to shelf attaches a panel but does not | 1349 // Tests that dragging a window down to shelf attaches a panel but does not |
1386 // attach a regular window. | 1350 // attach a regular window. |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1612 EXPECT_TRUE(window_state->IsMaximized()); | 1576 EXPECT_TRUE(window_state->IsMaximized()); |
1613 } | 1577 } |
1614 | 1578 |
1615 // Tests run twice - on both panels and normal windows | 1579 // Tests run twice - on both panels and normal windows |
1616 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1580 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
1617 DockedWindowResizerTest, | 1581 DockedWindowResizerTest, |
1618 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 1582 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
1619 ui::wm::WINDOW_TYPE_PANEL)); | 1583 ui::wm::WINDOW_TYPE_PANEL)); |
1620 | 1584 |
1621 } // namespace ash | 1585 } // namespace ash |
OLD | NEW |