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

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

Issue 224113005: Eliminate ash::internal namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/dock/docked_window_resizer.cc ('k') | ash/wm/drag_window_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shelf/shelf.h" 10 #include "ash/shelf/shelf.h"
(...skipping 19 matching lines...) Expand all
30 #include "ui/aura/client/window_tree_client.h" 30 #include "ui/aura/client/window_tree_client.h"
31 #include "ui/aura/test/event_generator.h" 31 #include "ui/aura/test/event_generator.h"
32 #include "ui/aura/test/test_window_delegate.h" 32 #include "ui/aura/test/test_window_delegate.h"
33 #include "ui/aura/window_event_dispatcher.h" 33 #include "ui/aura/window_event_dispatcher.h"
34 #include "ui/base/hit_test.h" 34 #include "ui/base/hit_test.h"
35 #include "ui/base/ui_base_types.h" 35 #include "ui/base/ui_base_types.h"
36 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
37 #include "ui/wm/core/window_util.h" 37 #include "ui/wm/core/window_util.h"
38 38
39 namespace ash { 39 namespace ash {
40 namespace internal {
41 40
42 class DockedWindowResizerTest 41 class DockedWindowResizerTest
43 : public test::AshTestBase, 42 : public test::AshTestBase,
44 public testing::WithParamInterface<ui::wm::WindowType> { 43 public testing::WithParamInterface<ui::wm::WindowType> {
45 public: 44 public:
46 DockedWindowResizerTest() : model_(NULL), window_type_(GetParam()) {} 45 DockedWindowResizerTest() : model_(NULL), window_type_(GetParam()) {}
47 virtual ~DockedWindowResizerTest() {} 46 virtual ~DockedWindowResizerTest() {}
48 47
49 virtual void SetUp() OVERRIDE { 48 virtual void SetUp() OVERRIDE {
50 AshTestBase::SetUp(); 49 AshTestBase::SetUp();
(...skipping 25 matching lines...) Expand all
76 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 75 aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
77 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( 76 aura::Window* window = CreateTestWindowInShellWithDelegateAndType(
78 &delegate_, 77 &delegate_,
79 window_type_, 78 window_type_,
80 0, 79 0,
81 bounds); 80 bounds);
82 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) { 81 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) {
83 test::TestShelfDelegate* shelf_delegate = 82 test::TestShelfDelegate* shelf_delegate =
84 test::TestShelfDelegate::instance(); 83 test::TestShelfDelegate::instance();
85 shelf_delegate->AddShelfItem(window); 84 shelf_delegate->AddShelfItem(window);
86 PanelLayoutManager* manager = 85 PanelLayoutManager* manager = static_cast<PanelLayoutManager*>(
87 static_cast<PanelLayoutManager*>( 86 Shell::GetContainer(window->GetRootWindow(),
88 Shell::GetContainer(window->GetRootWindow(), 87 kShellWindowId_PanelContainer)->layout_manager());
89 internal::kShellWindowId_PanelContainer)->
90 layout_manager());
91 manager->Relayout(); 88 manager->Relayout();
92 } 89 }
93 return window; 90 return window;
94 } 91 }
95 92
96 aura::Window* CreateModalWindow(const gfx::Rect& bounds) { 93 aura::Window* CreateModalWindow(const gfx::Rect& bounds) {
97 aura::Window* window = new aura::Window(&delegate_); 94 aura::Window* window = new aura::Window(&delegate_);
98 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); 95 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
99 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 96 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
100 window->Init(aura::WINDOW_LAYER_TEXTURED); 97 window->Init(aura::WINDOW_LAYER_TEXTURED);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 void DragRevert() { 160 void DragRevert() {
164 resizer_->RevertDrag(); 161 resizer_->RevertDrag();
165 resizer_.reset(); 162 resizer_.reset();
166 } 163 }
167 164
168 // Panels are parented by panel container during drags. 165 // Panels are parented by panel container during drags.
169 // All other windows that are tested here are parented by dock container 166 // All other windows that are tested here are parented by dock container
170 // during drags. 167 // during drags.
171 int CorrectContainerIdDuringDrag() { 168 int CorrectContainerIdDuringDrag() {
172 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) 169 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL)
173 return internal::kShellWindowId_PanelContainer; 170 return kShellWindowId_PanelContainer;
174 return internal::kShellWindowId_DockedContainer; 171 return kShellWindowId_DockedContainer;
175 } 172 }
176 173
177 // Test dragging the window vertically (to detach if it is a panel) and then 174 // Test dragging the window vertically (to detach if it is a panel) and then
178 // horizontally to the edge with an added offset from the edge of |dx|. 175 // horizontally to the edge with an added offset from the edge of |dx|.
179 void DragRelativeToEdge(DockedEdge edge, 176 void DragRelativeToEdge(DockedEdge edge,
180 aura::Window* window, 177 aura::Window* window,
181 int dx) { 178 int dx) {
182 DragVerticallyAndRelativeToEdge( 179 DragVerticallyAndRelativeToEdge(
183 edge, 180 edge,
184 window, 181 window,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 dx += work_area.x() - initial_location_in_screen.x(); 222 dx += work_area.x() - initial_location_in_screen.x();
226 else if (edge == DOCKED_EDGE_RIGHT) 223 else if (edge == DOCKED_EDGE_RIGHT)
227 dx += work_area.right() - 1 - initial_location_in_screen.x(); 224 dx += work_area.right() - 1 - initial_location_in_screen.x();
228 DragMove(dx, dy); 225 DragMove(dx, dy);
229 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 226 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
230 // Release the mouse and the panel should be attached to the dock. 227 // Release the mouse and the panel should be attached to the dock.
231 DragEnd(); 228 DragEnd();
232 229
233 // x-coordinate can get adjusted by snapping or sticking. 230 // x-coordinate can get adjusted by snapping or sticking.
234 // y-coordinate could be changed by possible automatic layout if docked. 231 // y-coordinate could be changed by possible automatic layout if docked.
235 if (window->parent()->id() != internal::kShellWindowId_DockedContainer && 232 if (window->parent()->id() != kShellWindowId_DockedContainer &&
236 !wm::GetWindowState(window)->HasRestoreBounds()) { 233 !wm::GetWindowState(window)->HasRestoreBounds()) {
237 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); 234 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y());
238 } 235 }
239 } 236 }
240 237
241 bool test_panels() const { return window_type_ == ui::wm::WINDOW_TYPE_PANEL; } 238 bool test_panels() const { return window_type_ == ui::wm::WINDOW_TYPE_PANEL; }
242 239
243 aura::test::TestWindowDelegate* delegate() { 240 aura::test::TestWindowDelegate* delegate() {
244 return &delegate_; 241 return &delegate_;
245 } 242 }
(...skipping 18 matching lines...) Expand all
264 TEST_P(DockedWindowResizerTest, AttachRightPrecise) { 261 TEST_P(DockedWindowResizerTest, AttachRightPrecise) {
265 if (!SupportsHostWindowResize()) 262 if (!SupportsHostWindowResize())
266 return; 263 return;
267 264
268 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 265 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
269 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 266 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
270 267
271 // The window should be docked at the right edge. 268 // The window should be docked at the right edge.
272 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 269 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
273 window->GetBoundsInScreen().right()); 270 window->GetBoundsInScreen().right());
274 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 271 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
275 } 272 }
276 273
277 // Verifies a window can be dragged and attached to the dock 274 // Verifies a window can be dragged and attached to the dock
278 // even if pointer overshoots the screen edge by a few pixels (sticky edge) 275 // even if pointer overshoots the screen edge by a few pixels (sticky edge)
279 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) { 276 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) {
280 if (!SupportsHostWindowResize()) 277 if (!SupportsHostWindowResize())
281 return; 278 return;
282 279
283 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 280 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
284 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4); 281 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4);
285 282
286 // The window should be docked at the right edge. 283 // The window should be docked at the right edge.
287 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 284 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
288 window->GetBoundsInScreen().right()); 285 window->GetBoundsInScreen().right());
289 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 286 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
290 } 287 }
291 288
292 // Verifies a window can be dragged and then if a pointer is not quite reaching 289 // Verifies a window can be dragged and then if a pointer is not quite reaching
293 // the screen edge the window does not get docked and stays in the desktop. 290 // the screen edge the window does not get docked and stays in the desktop.
294 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) { 291 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) {
295 if (!SupportsHostWindowResize()) 292 if (!SupportsHostWindowResize())
296 return; 293 return;
297 294
298 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 295 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
299 // Grabbing at 70px ensures that at least 30% of the window is in screen, 296 // Grabbing at 70px ensures that at least 30% of the window is in screen,
300 // otherwise the window would be adjusted in 297 // otherwise the window would be adjusted in
301 // WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded. 298 // WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded.
302 const int kGrabOffsetX = 70; 299 const int kGrabOffsetX = 70;
303 const int kUndershootBy = 1; 300 const int kUndershootBy = 1;
304 DragVerticallyAndRelativeToEdge(DOCKED_EDGE_RIGHT, 301 DragVerticallyAndRelativeToEdge(DOCKED_EDGE_RIGHT,
305 window.get(), 302 window.get(),
306 -kUndershootBy, test_panels() ? -100 : 20, 303 -kUndershootBy, test_panels() ? -100 : 20,
307 kGrabOffsetX, 5); 304 kGrabOffsetX, 5);
308 305
309 // The window right should be past the screen edge but not docked. 306 // The window right should be past the screen edge but not docked.
310 // Initial touch point is 70px to the right which helps to find where the edge 307 // Initial touch point is 70px to the right which helps to find where the edge
311 // should be. 308 // should be.
312 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right() + 309 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right() +
313 window->bounds().width() - kGrabOffsetX - kUndershootBy - 1, 310 window->bounds().width() - kGrabOffsetX - kUndershootBy - 1,
314 window->GetBoundsInScreen().right()); 311 window->GetBoundsInScreen().right());
315 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 312 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
316 window->parent()->id());
317 } 313 }
318 314
319 // Verifies a window can be dragged and attached to the dock. 315 // Verifies a window can be dragged and attached to the dock.
320 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { 316 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) {
321 if (!SupportsHostWindowResize()) 317 if (!SupportsHostWindowResize())
322 return; 318 return;
323 319
324 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 320 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
325 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); 321 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0);
326 322
327 // The window should be docked at the left edge. 323 // The window should be docked at the left edge.
328 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), 324 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(),
329 window->GetBoundsInScreen().x()); 325 window->GetBoundsInScreen().x());
330 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 326 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
331 } 327 }
332 328
333 // Verifies a window can be dragged and attached to the dock 329 // Verifies a window can be dragged and attached to the dock
334 // even if pointer overshoots the screen edge by a few pixels (sticky edge) 330 // even if pointer overshoots the screen edge by a few pixels (sticky edge)
335 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) { 331 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) {
336 if (!SupportsHostWindowResize()) 332 if (!SupportsHostWindowResize())
337 return; 333 return;
338 334
339 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 335 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
340 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4); 336 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4);
341 337
342 // The window should be docked at the left edge. 338 // The window should be docked at the left edge.
343 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), 339 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(),
344 window->GetBoundsInScreen().x()); 340 window->GetBoundsInScreen().x());
345 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 341 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
346 } 342 }
347 343
348 // Verifies a window can be dragged and then if a pointer is not quite reaching 344 // Verifies a window can be dragged and then if a pointer is not quite reaching
349 // the screen edge the window does not get docked and stays in the desktop. 345 // the screen edge the window does not get docked and stays in the desktop.
350 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) { 346 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) {
351 if (!SupportsHostWindowResize()) 347 if (!SupportsHostWindowResize())
352 return; 348 return;
353 349
354 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 350 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
355 gfx::Rect initial_bounds(window->bounds()); 351 gfx::Rect initial_bounds(window->bounds());
356 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1); 352 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1);
357 353
358 // The window should be crossing the screen edge but not docked. 354 // The window should be crossing the screen edge but not docked.
359 int expected_x = initial_bounds.x() - initial_location_in_parent().x() + 1; 355 int expected_x = initial_bounds.x() - initial_location_in_parent().x() + 1;
360 EXPECT_EQ(expected_x, window->GetBoundsInScreen().x()); 356 EXPECT_EQ(expected_x, window->GetBoundsInScreen().x());
361 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 357 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
362 window->parent()->id());
363 } 358 }
364 359
365 // Dock on the right side, change shelf alignment, check that windows move to 360 // Dock on the right side, change shelf alignment, check that windows move to
366 // the opposite side. 361 // the opposite side.
367 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) { 362 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) {
368 if (!SupportsHostWindowResize()) 363 if (!SupportsHostWindowResize())
369 return; 364 return;
370 365
371 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 366 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
372 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 367 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
373 368
374 // The window should be docked at the right edge. 369 // The window should be docked at the right edge.
375 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 370 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
376 window->GetBoundsInScreen().right()); 371 window->GetBoundsInScreen().right());
377 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 372 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
378 373
379 // set launcher shelf to be aligned on the right 374 // set launcher shelf to be aligned on the right
380 ash::Shell* shell = ash::Shell::GetInstance(); 375 ash::Shell* shell = ash::Shell::GetInstance();
381 shell->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, 376 shell->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT,
382 shell->GetPrimaryRootWindow()); 377 shell->GetPrimaryRootWindow());
383 // The window should have moved and get attached to the left dock. 378 // The window should have moved and get attached to the left dock.
384 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), 379 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(),
385 window->GetBoundsInScreen().x()); 380 window->GetBoundsInScreen().x());
386 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 381 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
387 382
388 // set launcher shelf to be aligned on the left 383 // set launcher shelf to be aligned on the left
389 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, 384 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT,
390 shell->GetPrimaryRootWindow()); 385 shell->GetPrimaryRootWindow());
391 // The window should have moved and get attached to the right edge. 386 // The window should have moved and get attached to the right edge.
392 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 387 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
393 window->GetBoundsInScreen().right()); 388 window->GetBoundsInScreen().right());
394 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 389 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
395 390
396 // set launcher shelf to be aligned at the bottom 391 // set launcher shelf to be aligned at the bottom
397 shell->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM, 392 shell->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM,
398 shell->GetPrimaryRootWindow()); 393 shell->GetPrimaryRootWindow());
399 // The window should stay in the right edge. 394 // The window should stay in the right edge.
400 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 395 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
401 window->GetBoundsInScreen().right()); 396 window->GetBoundsInScreen().right());
402 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 397 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
403 } 398 }
404 399
405 // Dock on the right side, try to undock, then drag more to really undock 400 // Dock on the right side, try to undock, then drag more to really undock
406 TEST_P(DockedWindowResizerTest, AttachTryDetach) { 401 TEST_P(DockedWindowResizerTest, AttachTryDetach) {
407 if (!SupportsHostWindowResize()) 402 if (!SupportsHostWindowResize())
408 return; 403 return;
409 404
410 scoped_ptr<aura::Window> window(CreateTestWindow( 405 scoped_ptr<aura::Window> window(CreateTestWindow(
411 gfx::Rect(0, 0, ideal_width() + 10, 201))); 406 gfx::Rect(0, 0, ideal_width() + 10, 201)));
412 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 407 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
413 408
414 // The window should be docked at the right edge. 409 // The window should be docked at the right edge.
415 // Its width should shrink to ideal width. 410 // Its width should shrink to ideal width.
416 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 411 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
417 window->GetBoundsInScreen().right()); 412 window->GetBoundsInScreen().right());
418 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); 413 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width());
419 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 414 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
420 415
421 // Try to detach by dragging left less than kSnapToDockDistance. 416 // Try to detach by dragging left less than kSnapToDockDistance.
422 // The window should stay docked. 417 // The window should stay docked.
423 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( 418 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(
424 window.get(), 10, 0)); 419 window.get(), 10, 0));
425 DragMove(-4, -10); 420 DragMove(-4, -10);
426 // Release the mouse and the window should be still attached to the dock. 421 // Release the mouse and the window should be still attached to the dock.
427 DragEnd(); 422 DragEnd();
428 423
429 // The window should be still attached to the right edge. 424 // The window should be still attached to the right edge.
430 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 425 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
431 window->GetBoundsInScreen().right()); 426 window->GetBoundsInScreen().right());
432 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 427 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
433 428
434 // Try to detach by dragging left by kSnapToDockDistance or more. 429 // Try to detach by dragging left by kSnapToDockDistance or more.
435 // The window should get undocked. 430 // The window should get undocked.
436 const int left_edge = window->bounds().x(); 431 const int left_edge = window->bounds().x();
437 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( 432 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(
438 window.get(), 10, 0)); 433 window.get(), 10, 0));
439 DragMove(-32, -10); 434 DragMove(-32, -10);
440 // Release the mouse and the window should be no longer attached to the dock. 435 // Release the mouse and the window should be no longer attached to the dock.
441 DragEnd(); 436 DragEnd();
442 437
443 // The window should be floating on the desktop again and moved to the left. 438 // The window should be floating on the desktop again and moved to the left.
444 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); 439 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x());
445 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 440 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
446 window->parent()->id());
447 } 441 }
448 442
449 // Dock on the right side, and undock by dragging the right edge of the window 443 // Dock on the right side, and undock by dragging the right edge of the window
450 // header. This test is useful because both the position of the dragged window 444 // header. This test is useful because both the position of the dragged window
451 // and the position of the mouse are used in determining whether a window should 445 // and the position of the mouse are used in determining whether a window should
452 // be undocked. 446 // be undocked.
453 TEST_P(DockedWindowResizerTest, AttachTryDetachDragRightEdgeOfHeader) { 447 TEST_P(DockedWindowResizerTest, AttachTryDetachDragRightEdgeOfHeader) {
454 if (!SupportsHostWindowResize()) 448 if (!SupportsHostWindowResize())
455 return; 449 return;
456 450
457 scoped_ptr<aura::Window> window(CreateTestWindow( 451 scoped_ptr<aura::Window> window(CreateTestWindow(
458 gfx::Rect(0, 0, ideal_width() + 10, 201))); 452 gfx::Rect(0, 0, ideal_width() + 10, 201)));
459 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 453 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
460 454
461 // The window should be docked at the right edge. 455 // The window should be docked at the right edge.
462 // Its width should shrink to ideal width. 456 // Its width should shrink to ideal width.
463 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 457 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
464 window->GetBoundsInScreen().right()); 458 window->GetBoundsInScreen().right());
465 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); 459 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width());
466 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 460 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
467 461
468 // Try to detach by dragging left less than kSnapToDockDistance. 462 // Try to detach by dragging left less than kSnapToDockDistance.
469 // The window should stay docked. 463 // The window should stay docked.
470 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( 464 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(
471 window.get(), ideal_width() - 10, 0)); 465 window.get(), ideal_width() - 10, 0));
472 DragMove(-4, -10); 466 DragMove(-4, -10);
473 // Release the mouse and the window should be still attached to the dock. 467 // Release the mouse and the window should be still attached to the dock.
474 DragEnd(); 468 DragEnd();
475 469
476 // The window should be still attached to the right edge. 470 // The window should be still attached to the right edge.
477 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 471 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
478 window->GetBoundsInScreen().right()); 472 window->GetBoundsInScreen().right());
479 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 473 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
480 474
481 // Try to detach by dragging left by kSnapToDockDistance or more. 475 // Try to detach by dragging left by kSnapToDockDistance or more.
482 // The window should get undocked. 476 // The window should get undocked.
483 const int left_edge = window->bounds().x(); 477 const int left_edge = window->bounds().x();
484 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( 478 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(
485 window.get(), ideal_width() - 10, 0)); 479 window.get(), ideal_width() - 10, 0));
486 DragMove(-32, -10); 480 DragMove(-32, -10);
487 // Release the mouse and the window should be no longer attached to the dock. 481 // Release the mouse and the window should be no longer attached to the dock.
488 DragEnd(); 482 DragEnd();
489 483
490 // The window should be floating on the desktop again and moved to the left. 484 // The window should be floating on the desktop again and moved to the left.
491 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); 485 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x());
492 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 486 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
493 window->parent()->id());
494 } 487 }
495 488
496 // Minimize a docked window, then restore it and check that it is still docked. 489 // Minimize a docked window, then restore it and check that it is still docked.
497 TEST_P(DockedWindowResizerTest, AttachMinimizeRestore) { 490 TEST_P(DockedWindowResizerTest, AttachMinimizeRestore) {
498 if (!SupportsHostWindowResize()) 491 if (!SupportsHostWindowResize())
499 return; 492 return;
500 493
501 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 494 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
502 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 495 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
503 496
504 // The window should be docked at the right edge. 497 // The window should be docked at the right edge.
505 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 498 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
506 window->GetBoundsInScreen().right()); 499 window->GetBoundsInScreen().right());
507 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 500 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
508 501
509 wm::WindowState* window_state = wm::GetWindowState(window.get()); 502 wm::WindowState* window_state = wm::GetWindowState(window.get());
510 // Minimize the window, it should be hidden. 503 // Minimize the window, it should be hidden.
511 window_state->Minimize(); 504 window_state->Minimize();
512 RunAllPendingInMessageLoop(); 505 RunAllPendingInMessageLoop();
513 EXPECT_FALSE(window->IsVisible()); 506 EXPECT_FALSE(window->IsVisible());
514 EXPECT_TRUE(window_state->IsMinimized()); 507 EXPECT_TRUE(window_state->IsMinimized());
515 // Restore the window; window should be visible. 508 // Restore the window; window should be visible.
516 window_state->Restore(); 509 window_state->Restore();
517 RunAllPendingInMessageLoop(); 510 RunAllPendingInMessageLoop();
518 EXPECT_TRUE(window->IsVisible()); 511 EXPECT_TRUE(window->IsVisible());
519 EXPECT_TRUE(window_state->IsNormalStateType()); 512 EXPECT_TRUE(window_state->IsNormalStateType());
520 } 513 }
521 514
522 // Maximize a docked window and check that it is maximized and no longer docked. 515 // Maximize a docked window and check that it is maximized and no longer docked.
523 TEST_P(DockedWindowResizerTest, AttachMaximize) { 516 TEST_P(DockedWindowResizerTest, AttachMaximize) {
524 if (!SupportsHostWindowResize()) 517 if (!SupportsHostWindowResize())
525 return; 518 return;
526 519
527 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 520 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
528 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 521 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
529 522
530 // The window should be docked at the right edge. 523 // The window should be docked at the right edge.
531 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 524 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
532 window->GetBoundsInScreen().right()); 525 window->GetBoundsInScreen().right());
533 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 526 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
534 527
535 wm::WindowState* window_state = wm::GetWindowState(window.get()); 528 wm::WindowState* window_state = wm::GetWindowState(window.get());
536 // Maximize the window, it should get undocked and maximized in a desktop. 529 // Maximize the window, it should get undocked and maximized in a desktop.
537 window_state->Maximize(); 530 window_state->Maximize();
538 RunAllPendingInMessageLoop(); 531 RunAllPendingInMessageLoop();
539 EXPECT_TRUE(window->IsVisible()); 532 EXPECT_TRUE(window->IsVisible());
540 EXPECT_TRUE(window_state->IsMaximized()); 533 EXPECT_TRUE(window_state->IsMaximized());
541 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); 534 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
542 } 535 }
543 536
544 // Dock two windows, undock one, check that the other one is still docked. 537 // Dock two windows, undock one, check that the other one is still docked.
545 TEST_P(DockedWindowResizerTest, AttachTwoWindows) { 538 TEST_P(DockedWindowResizerTest, AttachTwoWindows) {
546 if (!SupportsHostWindowResize()) 539 if (!SupportsHostWindowResize())
547 return; 540 return;
548 UpdateDisplay("600x600"); 541 UpdateDisplay("600x600");
549 542
550 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 543 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
551 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 544 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
552 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 545 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
553 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 50); 546 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 50);
554 547
555 // Docking second window should not minimize the first. 548 // Docking second window should not minimize the first.
556 wm::WindowState* window_state1 = wm::GetWindowState(w1.get()); 549 wm::WindowState* window_state1 = wm::GetWindowState(w1.get());
557 EXPECT_FALSE(window_state1->IsMinimized()); 550 EXPECT_FALSE(window_state1->IsMinimized());
558 551
559 // Both windows should be docked at the right edge. 552 // Both windows should be docked at the right edge.
560 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 553 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
561 w1->GetBoundsInScreen().right()); 554 w1->GetBoundsInScreen().right());
562 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 555 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
563 556
564 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), 557 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(),
565 w2->GetBoundsInScreen().right()); 558 w2->GetBoundsInScreen().right());
566 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 559 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
567 560
568 // Detach by dragging left (should get undocked). 561 // Detach by dragging left (should get undocked).
569 const int left_edge = w2->bounds().x(); 562 const int left_edge = w2->bounds().x();
570 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get())); 563 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get()));
571 // Drag up as well to avoid attaching panels to launcher shelf. 564 // Drag up as well to avoid attaching panels to launcher shelf.
572 DragMove(-32, -100); 565 DragMove(-32, -100);
573 // Release the mouse and the window should be no longer attached to the edge. 566 // Release the mouse and the window should be no longer attached to the edge.
574 DragEnd(); 567 DragEnd();
575 568
576 // The first window should be still docked. 569 // The first window should be still docked.
577 EXPECT_FALSE(window_state1->IsMinimized()); 570 EXPECT_FALSE(window_state1->IsMinimized());
578 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 571 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
579 w1->GetBoundsInScreen().right()); 572 w1->GetBoundsInScreen().right());
580 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 573 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
581 574
582 // The window should be floating on the desktop again and moved to the left. 575 // The window should be floating on the desktop again and moved to the left.
583 EXPECT_EQ(left_edge - 32, w2->GetBoundsInScreen().x()); 576 EXPECT_EQ(left_edge - 32, w2->GetBoundsInScreen().x());
584 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 577 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
585 w2->parent()->id());
586 } 578 }
587 579
588 // Create two windows, dock one and change shelf to auto-hide. 580 // Create two windows, dock one and change shelf to auto-hide.
589 TEST_P(DockedWindowResizerTest, AttachOneAutoHideShelf) { 581 TEST_P(DockedWindowResizerTest, AttachOneAutoHideShelf) {
590 if (!SupportsHostWindowResize()) 582 if (!SupportsHostWindowResize())
591 return; 583 return;
592 584
593 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 585 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
594 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 586 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
595 587
596 // w1 should be docked at the right edge. 588 // w1 should be docked at the right edge.
597 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 589 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
598 w1->GetBoundsInScreen().right()); 590 w1->GetBoundsInScreen().right());
599 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 591 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
600 592
601 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( 593 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType(
602 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); 594 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20)));
603 wm::GetWindowState(w2.get())->Maximize(); 595 wm::GetWindowState(w2.get())->Maximize();
604 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 596 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
605 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); 597 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized());
606 598
607 gfx::Rect work_area = 599 gfx::Rect work_area =
608 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); 600 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area();
609 DockedWindowLayoutManager* manager = 601 DockedWindowLayoutManager* manager =
610 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 602 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
611 603
612 // Docked window should be centered vertically in the work area. 604 // Docked window should be centered vertically in the work area.
613 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); 605 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y());
614 // Docked background should extend to the bottom of work area. 606 // Docked background should extend to the bottom of work area.
(...skipping 19 matching lines...) Expand all
634 626
635 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 627 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
636 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 628 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
637 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 629 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
638 gfx::Rect initial_bounds(w2->bounds()); 630 gfx::Rect initial_bounds(w2->bounds());
639 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); 631 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50);
640 632
641 // The first window should be docked at the right edge. 633 // The first window should be docked at the right edge.
642 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 634 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
643 w1->GetBoundsInScreen().right()); 635 w1->GetBoundsInScreen().right());
644 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 636 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
645 637
646 // The second window should be near the left edge but not snapped. 638 // The second window should be near the left edge but not snapped.
647 // Normal window will get side-maximized while panels will not. 639 // Normal window will get side-maximized while panels will not.
648 int expected_x = test_panels() ? 640 int expected_x = test_panels() ?
649 (initial_bounds.x() - initial_location_in_parent().x()) : 0; 641 (initial_bounds.x() - initial_location_in_parent().x()) : 0;
650 EXPECT_EQ(expected_x, w2->GetBoundsInScreen().x()); 642 EXPECT_EQ(expected_x, w2->GetBoundsInScreen().x());
651 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 643 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
652 } 644 }
653 645
654 // Tests that reverting a drag restores docked state if a window was docked. 646 // Tests that reverting a drag restores docked state if a window was docked.
655 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { 647 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) {
656 if (!SupportsHostWindowResize()) 648 if (!SupportsHostWindowResize())
657 return; 649 return;
658 650
659 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 651 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
660 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 652 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
661 653
662 // The window should be docked at the right edge. 654 // The window should be docked at the right edge.
663 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 655 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
664 window->GetBoundsInScreen().right()); 656 window->GetBoundsInScreen().right());
665 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 657 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
666 658
667 // Drag the window out but revert the drag 659 // Drag the window out but revert the drag
668 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); 660 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
669 DragMove(-50, 0); 661 DragMove(-50, 0);
670 DragRevert(); 662 DragRevert();
671 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 663 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
672 664
673 // Detach window. 665 // Detach window.
674 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); 666 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
675 DragMove(-50, 0); 667 DragMove(-50, 0);
676 DragEnd(); 668 DragEnd();
677 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 669 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
678 window->parent()->id());
679 } 670 }
680 671
681 // Tests that reverting drag restores undocked state if a window was not docked. 672 // Tests that reverting drag restores undocked state if a window was not docked.
682 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { 673 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) {
683 if (!SupportsHostWindowResize()) 674 if (!SupportsHostWindowResize())
684 return; 675 return;
685 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 676 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
686 aura::Window* dock_container = Shell::GetContainer( 677 aura::Window* dock_container = Shell::GetContainer(
687 window->GetRootWindow(), 678 window->GetRootWindow(),
688 kShellWindowId_DockedContainer); 679 kShellWindowId_DockedContainer);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 723 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
733 EXPECT_EQ(2, static_cast<int>(root_windows.size())); 724 EXPECT_EQ(2, static_cast<int>(root_windows.size()));
734 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 725 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
735 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 726 gfx::Rect initial_bounds = window->GetBoundsInScreen();
736 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 727 EXPECT_EQ(root_windows[0], window->GetRootWindow());
737 728
738 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 729 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
739 // The window should be docked at the right edge. 730 // The window should be docked at the right edge.
740 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 731 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
741 window->GetBoundsInScreen().right()); 732 window->GetBoundsInScreen().right());
742 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 733 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
743 734
744 // Try dragging to the right - enough to get it peeking at the other screen 735 // Try dragging to the right - enough to get it peeking at the other screen
745 // but not enough to land in the other screen. 736 // but not enough to land in the other screen.
746 // The window should stay on the left screen. 737 // The window should stay on the left screen.
747 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); 738 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
748 DragMove(100, 0); 739 DragMove(100, 0);
749 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 740 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
750 DragEnd(); 741 DragEnd();
751 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 742 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
752 window->GetBoundsInScreen().right()); 743 window->GetBoundsInScreen().right());
753 EXPECT_EQ(internal::kShellWindowId_DockedContainer, 744 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
754 window->parent()->id());
755 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 745 EXPECT_EQ(root_windows[0], window->GetRootWindow());
756 746
757 // Undock and move to the right - enough to get the mouse pointer past the 747 // Undock and move to the right - enough to get the mouse pointer past the
758 // edge of the screen and into the second screen. The window should now be 748 // edge of the screen and into the second screen. The window should now be
759 // in the second screen and not docked. 749 // in the second screen and not docked.
760 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( 750 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(
761 window.get(), 751 window.get(),
762 window->bounds().width()/2 + 10, 752 window->bounds().width()/2 + 10,
763 0)); 753 0));
764 DragMove(window->bounds().width()/2 - 5, 0); 754 DragMove(window->bounds().width()/2 - 5, 0);
765 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 755 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
766 DragEnd(); 756 DragEnd();
767 EXPECT_NE(window->GetRootWindow()->GetBoundsInScreen().right(), 757 EXPECT_NE(window->GetRootWindow()->GetBoundsInScreen().right(),
768 window->GetBoundsInScreen().right()); 758 window->GetBoundsInScreen().right());
769 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 759 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
770 window->parent()->id());
771 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 760 EXPECT_EQ(root_windows[1], window->GetRootWindow());
772 761
773 // Keep dragging it to the right until its left edge touches the screen edge. 762 // Keep dragging it to the right until its left edge touches the screen edge.
774 // The window should now be in the second screen and not docked. 763 // The window should now be in the second screen and not docked.
775 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( 764 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(
776 window.get(), 765 window.get(),
777 window->bounds().width()/2 + 10, 766 window->bounds().width()/2 + 10,
778 0)); 767 0));
779 DragMove(window->GetRootWindow()->GetBoundsInScreen().x() - 768 DragMove(window->GetRootWindow()->GetBoundsInScreen().x() -
780 window->GetBoundsInScreen().x(), 769 window->GetBoundsInScreen().x(),
781 0); 770 0);
782 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 771 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
783 DragEnd(); 772 DragEnd();
784 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), 773 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(),
785 window->GetBoundsInScreen().x()); 774 window->GetBoundsInScreen().x());
786 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); 775 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
787 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 776 EXPECT_EQ(root_windows[1], window->GetRootWindow());
788 } 777 }
789 778
790 // Dock two windows, undock one. 779 // Dock two windows, undock one.
791 // Test the docked windows area size and default container resizing. 780 // Test the docked windows area size and default container resizing.
792 TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) { 781 TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) {
793 if (!SupportsHostWindowResize()) 782 if (!SupportsHostWindowResize())
794 return; 783 return;
795 UpdateDisplay("600x600"); 784 UpdateDisplay("600x600");
796 785
797 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 786 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
798 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); 787 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201)));
799 // Work area should cover the whole screen. 788 // Work area should cover the whole screen.
800 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), 789 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(),
801 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 790 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
802 791
803 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 792 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
804 // A window should be docked at the right edge. 793 // A window should be docked at the right edge.
805 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 794 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
806 w1->GetBoundsInScreen().right()); 795 w1->GetBoundsInScreen().right());
807 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 796 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
808 DockedWindowLayoutManager* manager = 797 DockedWindowLayoutManager* manager =
809 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 798 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
810 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 799 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
811 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 800 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
812 801
813 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); 802 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100);
814 // Both windows should now be docked at the right edge. 803 // Both windows should now be docked at the right edge.
815 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), 804 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(),
816 w2->GetBoundsInScreen().right()); 805 w2->GetBoundsInScreen().right());
817 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 806 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
818 // Dock width should be set to a wider window. 807 // Dock width should be set to a wider window.
819 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 808 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
820 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), 809 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()),
821 docked_width(manager)); 810 docked_width(manager));
822 811
823 // Try to detach by dragging left a bit (should not get undocked). 812 // Try to detach by dragging left a bit (should not get undocked).
824 // This would normally detach a single docked window but since we have another 813 // This would normally detach a single docked window but since we have another
825 // window and the mouse pointer does not leave the dock area the window 814 // window and the mouse pointer does not leave the dock area the window
826 // should stay docked. 815 // should stay docked.
827 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 60, 0)); 816 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 60, 0));
828 // Drag up as well as left to avoid attaching panels to launcher shelf. 817 // Drag up as well as left to avoid attaching panels to launcher shelf.
829 DragMove(-40, -40); 818 DragMove(-40, -40);
830 // Release the mouse and the window should be still attached to the edge. 819 // Release the mouse and the window should be still attached to the edge.
831 DragEnd(); 820 DragEnd();
832 821
833 // The first window should be still docked. 822 // The first window should be still docked.
834 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 823 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
835 w1->GetBoundsInScreen().right()); 824 w1->GetBoundsInScreen().right());
836 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 825 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
837 826
838 // The second window should be still docked. 827 // The second window should be still docked.
839 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), 828 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(),
840 w2->GetBoundsInScreen().right()); 829 w2->GetBoundsInScreen().right());
841 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 830 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
842 831
843 // Detach by dragging left more (should get undocked). 832 // Detach by dragging left more (should get undocked).
844 const int left_edge = w2->bounds().x(); 833 const int left_edge = w2->bounds().x();
845 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( 834 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(
846 w2.get(), 835 w2.get(),
847 w2->bounds().width()/2 + 10, 836 w2->bounds().width()/2 + 10,
848 0)); 837 0));
849 // Drag up as well to avoid attaching panels to launcher shelf. 838 // Drag up as well to avoid attaching panels to launcher shelf.
850 const int drag_x = -(w2->bounds().width()/2 + 20); 839 const int drag_x = -(w2->bounds().width()/2 + 20);
851 DragMove(drag_x, -100); 840 DragMove(drag_x, -100);
852 // Release the mouse and the window should be no longer attached to the edge. 841 // Release the mouse and the window should be no longer attached to the edge.
853 DragEnd(); 842 DragEnd();
854 843
855 // The second window should be floating on the desktop again. 844 // The second window should be floating on the desktop again.
856 EXPECT_EQ(left_edge + drag_x, w2->bounds().x()); 845 EXPECT_EQ(left_edge + drag_x, w2->bounds().x());
857 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 846 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
858 // Dock width should be set to remaining single docked window. 847 // Dock width should be set to remaining single docked window.
859 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 848 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
860 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 849 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
861 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 850 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
862 } 851 }
863 852
864 // Dock one of the windows. Maximize other testing desktop resizing. 853 // Dock one of the windows. Maximize other testing desktop resizing.
865 TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) { 854 TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) {
866 if (!SupportsHostWindowResize()) 855 if (!SupportsHostWindowResize())
867 return; 856 return;
868 857
869 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 858 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
870 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); 859 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201)));
871 // Work area should cover the whole screen. 860 // Work area should cover the whole screen.
872 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), 861 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(),
873 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 862 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
874 863
875 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 864 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
876 // A window should be docked at the right edge. 865 // A window should be docked at the right edge.
877 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 866 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
878 w1->GetBoundsInScreen().right()); 867 w1->GetBoundsInScreen().right());
879 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 868 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
880 DockedWindowLayoutManager* manager = 869 DockedWindowLayoutManager* manager =
881 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 870 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
882 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 871 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
883 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 872 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
884 873
885 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5)); 874 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5));
886 DragMove(w2->GetRootWindow()->bounds().width() 875 DragMove(w2->GetRootWindow()->bounds().width()
887 -w2->bounds().width() 876 -w2->bounds().width()
888 -(w2->bounds().width()/2 + 20) 877 -(w2->bounds().width()/2 + 20)
889 -w2->bounds().x(), 878 -w2->bounds().x(),
890 50 - w2->bounds().y()); 879 50 - w2->bounds().y());
891 DragEnd(); 880 DragEnd();
892 // The first window should be still docked. 881 // The first window should be still docked.
893 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 882 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
894 w1->GetBoundsInScreen().right()); 883 w1->GetBoundsInScreen().right());
895 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 884 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
896 885
897 // The second window should be floating on the desktop. 886 // The second window should be floating on the desktop.
898 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right() - 887 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right() -
899 (w2->bounds().width()/2 + 20), 888 (w2->bounds().width()/2 + 20),
900 w2->GetBoundsInScreen().right()); 889 w2->GetBoundsInScreen().right());
901 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 890 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
902 // Dock width should be set to remaining single docked window. 891 // Dock width should be set to remaining single docked window.
903 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 892 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
904 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 893 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
905 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 894 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
906 // Desktop work area should now shrink. 895 // Desktop work area should now shrink.
907 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - 896 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() -
908 docked_width(manager) - min_dock_gap(), 897 docked_width(manager) - min_dock_gap(),
909 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 898 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
910 899
911 // Maximize the second window - Maximized area should be shrunk. 900 // Maximize the second window - Maximized area should be shrunk.
912 const gfx::Rect restored_bounds = w2->bounds(); 901 const gfx::Rect restored_bounds = w2->bounds();
913 wm::WindowState* w2_state = wm::GetWindowState(w2.get()); 902 wm::WindowState* w2_state = wm::GetWindowState(w2.get());
914 w2_state->Maximize(); 903 w2_state->Maximize();
915 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - 904 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() -
916 docked_width(manager) - min_dock_gap(), 905 docked_width(manager) - min_dock_gap(),
917 w2->bounds().width()); 906 w2->bounds().width());
918 907
919 // Detach the first window (this should require very little drag). 908 // Detach the first window (this should require very little drag).
920 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); 909 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get()));
921 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 910 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
922 DragMove(-35, 10); 911 DragMove(-35, 10);
923 // Alignment is set to "NONE" when drag starts. 912 // Alignment is set to "NONE" when drag starts.
924 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); 913 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
925 // Release the mouse and the window should be no longer attached to the edge. 914 // Release the mouse and the window should be no longer attached to the edge.
926 DragEnd(); 915 DragEnd();
927 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); 916 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
928 // Dock should get shrunk and desktop should get expanded. 917 // Dock should get shrunk and desktop should get expanded.
929 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w1->parent()->id()); 918 EXPECT_EQ(kShellWindowId_DefaultContainer, w1->parent()->id());
930 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 919 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
931 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); 920 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
932 EXPECT_EQ(0, docked_width(manager)); 921 EXPECT_EQ(0, docked_width(manager));
933 // The second window should now get resized and take up the whole screen. 922 // The second window should now get resized and take up the whole screen.
934 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), 923 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(),
935 w2->bounds().width()); 924 w2->bounds().width());
936 925
937 // Dock the first window to the left edge. 926 // Dock the first window to the left edge.
938 // Click at an offset from origin to prevent snapping. 927 // Click at an offset from origin to prevent snapping.
939 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w1.get(), 10, 0)); 928 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w1.get(), 10, 0));
940 // Drag left to get pointer touching the screen edge. 929 // Drag left to get pointer touching the screen edge.
941 DragMove(-w1->bounds().x() - 10, 0); 930 DragMove(-w1->bounds().x() - 10, 0);
942 // Alignment set to "NONE" during the drag of the window when none are docked. 931 // Alignment set to "NONE" during the drag of the window when none are docked.
943 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); 932 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
944 // Release the mouse and the window should be now attached to the edge. 933 // Release the mouse and the window should be now attached to the edge.
945 DragEnd(); 934 DragEnd();
946 // Dock should get expanded and desktop should get shrunk. 935 // Dock should get expanded and desktop should get shrunk.
947 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 936 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
948 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); 937 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager));
949 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 938 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
950 // Second window should still be in the desktop. 939 // Second window should still be in the desktop.
951 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 940 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
952 // Maximized window should be shrunk. 941 // Maximized window should be shrunk.
953 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - 942 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() -
954 docked_width(manager) - min_dock_gap(), 943 docked_width(manager) - min_dock_gap(),
955 w2->bounds().width()); 944 w2->bounds().width());
956 945
957 // Unmaximize the second window. 946 // Unmaximize the second window.
958 w2_state->Restore(); 947 w2_state->Restore();
959 // Its bounds should get restored. 948 // Its bounds should get restored.
960 EXPECT_EQ(restored_bounds, w2->bounds()); 949 EXPECT_EQ(restored_bounds, w2->bounds());
961 } 950 }
962 951
963 // Dock one window. Test the sticky behavior near screen or desktop edge. 952 // Dock one window. Test the sticky behavior near screen or desktop edge.
964 TEST_P(DockedWindowResizerTest, AttachOneTestSticky) { 953 TEST_P(DockedWindowResizerTest, AttachOneTestSticky) {
965 if (!SupportsHostWindowResize()) 954 if (!SupportsHostWindowResize())
966 return; 955 return;
967 956
968 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 957 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
969 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); 958 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201)));
970 // Work area should cover the whole screen. 959 // Work area should cover the whole screen.
971 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), 960 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(),
972 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 961 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
973 962
974 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); 963 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20);
975 // A window should be docked at the left edge. 964 // A window should be docked at the left edge.
976 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), 965 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(),
977 w1->GetBoundsInScreen().x()); 966 w1->GetBoundsInScreen().x());
978 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 967 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
979 DockedWindowLayoutManager* manager = 968 DockedWindowLayoutManager* manager =
980 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 969 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
981 // The first window should be docked. 970 // The first window should be docked.
982 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), 971 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(),
983 w1->GetBoundsInScreen().x()); 972 w1->GetBoundsInScreen().x());
984 // Dock width should be set to that of a single docked window. 973 // Dock width should be set to that of a single docked window.
985 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 974 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
986 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); 975 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager));
987 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 976 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
988 977
989 // Position second window in the desktop 20px to the right of the docked w1. 978 // Position second window in the desktop 20px to the right of the docked w1.
990 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, 979 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT,
991 w2.get(), 980 w2.get(),
992 20 + 25 - 981 20 + 25 -
993 min_dock_gap(), 982 min_dock_gap(),
994 50); 983 50);
995 // The second window should be floating on the desktop. 984 // The second window should be floating on the desktop.
996 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().x() + 985 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().x() +
997 (w1->bounds().right() + 20), 986 (w1->bounds().right() + 20),
998 w2->GetBoundsInScreen().x()); 987 w2->GetBoundsInScreen().x());
999 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 988 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
1000 // Dock width should be set to that of a single docked window. 989 // Dock width should be set to that of a single docked window.
1001 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 990 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1002 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); 991 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager));
1003 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 992 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1004 993
1005 // Drag w2 almost to the dock, the mouse pointer not quite reaching the dock. 994 // Drag w2 almost to the dock, the mouse pointer not quite reaching the dock.
1006 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 10, 0)); 995 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 10, 0));
1007 DragMove(1 + docked_width(manager) - w2->bounds().x(), 0); 996 DragMove(1 + docked_width(manager) - w2->bounds().x(), 0);
1008 // Alignment set to "LEFT" during the drag because dock has a window in it. 997 // Alignment set to "LEFT" during the drag because dock has a window in it.
1009 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); 998 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager));
1010 // Release the mouse and the window should not be attached to the edge. 999 // Release the mouse and the window should not be attached to the edge.
1011 DragEnd(); 1000 DragEnd();
1012 // Dock should still have only one window in it. 1001 // Dock should still have only one window in it.
1013 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); 1002 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager));
1014 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1003 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1015 // The second window should still be in the desktop. 1004 // The second window should still be in the desktop.
1016 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1005 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1017 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 1006 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
1018 1007
1019 // Drag w2 by a bit more - it should resist the drag (stuck edges) 1008 // Drag w2 by a bit more - it should resist the drag (stuck edges)
1020 int start_x = w2->bounds().x(); 1009 int start_x = w2->bounds().x();
1021 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 100, 5)); 1010 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 100, 5));
1022 DragMove(-2, 0); 1011 DragMove(-2, 0);
1023 // Window should not actually move. 1012 // Window should not actually move.
1024 EXPECT_EQ(start_x, w2->bounds().x()); 1013 EXPECT_EQ(start_x, w2->bounds().x());
1025 // Alignment set to "LEFT" during the drag because dock has a window in it. 1014 // Alignment set to "LEFT" during the drag because dock has a window in it.
1026 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); 1015 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager));
1027 // Release the mouse and the window should not be attached to the edge. 1016 // Release the mouse and the window should not be attached to the edge.
1028 DragEnd(); 1017 DragEnd();
1029 // Window should be still where it was before the last drag started. 1018 // Window should be still where it was before the last drag started.
1030 EXPECT_EQ(start_x, w2->bounds().x()); 1019 EXPECT_EQ(start_x, w2->bounds().x());
1031 // Dock should still have only one window in it 1020 // Dock should still have only one window in it
1032 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); 1021 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager));
1033 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1022 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1034 // The second window should still be in the desktop 1023 // The second window should still be in the desktop
1035 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1024 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1036 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 1025 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
1037 1026
1038 // Drag w2 by more than the stuck threshold and drop it into the dock. 1027 // Drag w2 by more than the stuck threshold and drop it into the dock.
1039 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get())); 1028 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get()));
1040 DragMove(-100, 0); 1029 DragMove(-100, 0);
1041 // Window should actually move. 1030 // Window should actually move.
1042 EXPECT_NE(start_x, w2->bounds().x()); 1031 EXPECT_NE(start_x, w2->bounds().x());
1043 // Alignment set to "LEFT" during the drag because dock has a window in it. 1032 // Alignment set to "LEFT" during the drag because dock has a window in it.
1044 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); 1033 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager));
1045 // Release the mouse and the window should be attached to the edge. 1034 // Release the mouse and the window should be attached to the edge.
1046 DragEnd(); 1035 DragEnd();
1047 // Both windows are docked now. 1036 // Both windows are docked now.
1048 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1037 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1049 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 1038 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
1050 // Dock should get expanded and desktop should get shrunk. 1039 // Dock should get expanded and desktop should get shrunk.
1051 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); 1040 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager));
1052 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), 1041 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()),
1053 docked_width(manager)); 1042 docked_width(manager));
1054 // Desktop work area should now shrink by dock width. 1043 // Desktop work area should now shrink by dock width.
1055 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - 1044 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() -
1056 docked_width(manager) - min_dock_gap(), 1045 docked_width(manager) - min_dock_gap(),
1057 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 1046 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
1058 } 1047 }
1059 1048
1060 // Dock two windows, resize one. 1049 // Dock two windows, resize one.
1061 // Test the docked windows area size and remaining desktop resizing. 1050 // Test the docked windows area size and remaining desktop resizing.
1062 TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { 1051 TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) {
1063 if (!SupportsHostWindowResize()) 1052 if (!SupportsHostWindowResize())
1064 return; 1053 return;
1065 1054
1066 // Wider display to start since panels are limited to half the display width. 1055 // Wider display to start since panels are limited to half the display width.
1067 UpdateDisplay("1000x600"); 1056 UpdateDisplay("1000x600");
1068 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1057 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1069 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); 1058 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201)));
1070 // Work area should cover the whole screen. 1059 // Work area should cover the whole screen.
1071 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), 1060 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(),
1072 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 1061 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
1073 1062
1074 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1063 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1075 // A window should be docked at the right edge. 1064 // A window should be docked at the right edge.
1076 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 1065 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
1077 w1->GetBoundsInScreen().right()); 1066 w1->GetBoundsInScreen().right());
1078 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1067 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1079 DockedWindowLayoutManager* manager = 1068 DockedWindowLayoutManager* manager =
1080 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1069 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
1081 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1070 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1082 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1071 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1083 1072
1084 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); 1073 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100);
1085 // Both windows should now be docked at the right edge. 1074 // Both windows should now be docked at the right edge.
1086 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), 1075 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(),
1087 w2->GetBoundsInScreen().right()); 1076 w2->GetBoundsInScreen().right());
1088 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 1077 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
1089 // Dock width should be set to a wider window. 1078 // Dock width should be set to a wider window.
1090 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1079 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1091 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), 1080 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()),
1092 docked_width(manager)); 1081 docked_width(manager));
1093 1082
1094 // Resize the first window left by a bit and test that the dock expands. 1083 // Resize the first window left by a bit and test that the dock expands.
1095 int previous_width = w1->bounds().width(); 1084 int previous_width = w1->bounds().width();
1096 const int kResizeSpan1 = 30; 1085 const int kResizeSpan1 = 30;
1097 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), 1086 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(),
1098 0, 20, 1087 0, 20,
1099 HTLEFT)); 1088 HTLEFT));
1100 DragMove(-kResizeSpan1, 0); 1089 DragMove(-kResizeSpan1, 0);
1101 // Alignment set to "RIGHT" during the drag because dock has a window in it. 1090 // Alignment set to "RIGHT" during the drag because dock has a window in it.
1102 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1091 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1103 // Release the mouse and the window should be attached to the edge. 1092 // Release the mouse and the window should be attached to the edge.
1104 DragEnd(); 1093 DragEnd();
1105 // Dock should still have both windows in it. 1094 // Dock should still have both windows in it.
1106 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1095 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1107 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 1096 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
1108 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1097 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1109 // w1 is now wider than before. The dock should expand and be as wide as w1. 1098 // w1 is now wider than before. The dock should expand and be as wide as w1.
1110 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width()); 1099 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width());
1111 // Both windows should get resized since they both don't have min/max size. 1100 // Both windows should get resized since they both don't have min/max size.
1112 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); 1101 EXPECT_EQ(w1->bounds().width(), w2->bounds().width());
1113 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1102 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1114 // Desktop work area should shrink. 1103 // Desktop work area should shrink.
1115 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - 1104 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() -
1116 docked_width(manager) - min_dock_gap(), 1105 docked_width(manager) - min_dock_gap(),
1117 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 1106 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
1118 1107
1119 // Resize the first window left by more than the dock maximum width. 1108 // Resize the first window left by more than the dock maximum width.
1120 // This should cause the window width to be restricted by maximum dock width. 1109 // This should cause the window width to be restricted by maximum dock width.
1121 previous_width = w1->bounds().width(); 1110 previous_width = w1->bounds().width();
1122 const int kResizeSpan2 = 250; 1111 const int kResizeSpan2 = 250;
1123 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), 1112 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(),
1124 0, 20, 1113 0, 20,
1125 HTLEFT)); 1114 HTLEFT));
1126 DragMove(-kResizeSpan2, 0); 1115 DragMove(-kResizeSpan2, 0);
1127 // Alignment set to "RIGHT" during the drag because dock has a window in it. 1116 // Alignment set to "RIGHT" during the drag because dock has a window in it.
1128 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1117 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1129 // Release the mouse and the window should be attached to the edge. 1118 // Release the mouse and the window should be attached to the edge.
1130 DragEnd(); 1119 DragEnd();
1131 // Dock should still have both windows in it. 1120 // Dock should still have both windows in it.
1132 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1121 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1133 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 1122 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
1134 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1123 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1135 // w1 is now as wide as the maximum dock width and the dock should get 1124 // w1 is now as wide as the maximum dock width and the dock should get
1136 // resized to the maximum width. 1125 // resized to the maximum width.
1137 EXPECT_EQ(max_width(), w1->bounds().width()); 1126 EXPECT_EQ(max_width(), w1->bounds().width());
1138 // 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.
1139 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); 1128 EXPECT_EQ(w1->bounds().width(), w2->bounds().width());
1140 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1129 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1141 // Desktop work area should shrink. 1130 // Desktop work area should shrink.
1142 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - 1131 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() -
1143 docked_width(manager) - min_dock_gap(), 1132 docked_width(manager) - min_dock_gap(),
1144 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 1133 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
1145 1134
1146 // Resize the first window right to get it completely inside the docked area. 1135 // Resize the first window right to get it completely inside the docked area.
1147 previous_width = w1->bounds().width(); 1136 previous_width = w1->bounds().width();
1148 const int kResizeSpan3 = 100; 1137 const int kResizeSpan3 = 100;
1149 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), 1138 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(),
1150 0, 20, 1139 0, 20,
1151 HTLEFT)); 1140 HTLEFT));
1152 DragMove(kResizeSpan3, 0); 1141 DragMove(kResizeSpan3, 0);
1153 // Alignment set to "RIGHT" during the drag because dock has a window in it. 1142 // Alignment set to "RIGHT" during the drag because dock has a window in it.
1154 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1143 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1155 // Release the mouse and the window should be docked. 1144 // Release the mouse and the window should be docked.
1156 DragEnd(); 1145 DragEnd();
1157 // Dock should still have both windows in it. 1146 // Dock should still have both windows in it.
1158 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1147 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1159 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 1148 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
1160 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1149 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1161 // w1 should be narrower than before by the length of the drag. 1150 // w1 should be narrower than before by the length of the drag.
1162 EXPECT_EQ(previous_width - kResizeSpan3, w1->bounds().width()); 1151 EXPECT_EQ(previous_width - kResizeSpan3, w1->bounds().width());
1163 // Both windows should get resized since they both don't have min/max size. 1152 // Both windows should get resized since they both don't have min/max size.
1164 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); 1153 EXPECT_EQ(w1->bounds().width(), w2->bounds().width());
1165 // The dock should be as wide as w1 or w2. 1154 // The dock should be as wide as w1 or w2.
1166 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1155 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1167 // Desktop work area should shrink. 1156 // Desktop work area should shrink.
1168 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - 1157 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() -
1169 docked_width(manager) - min_dock_gap(), 1158 docked_width(manager) - min_dock_gap(),
1170 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 1159 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
1171 1160
1172 // Resize the first window left to be overhang again. 1161 // Resize the first window left to be overhang again.
1173 previous_width = w1->bounds().width(); 1162 previous_width = w1->bounds().width();
1174 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), 1163 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(),
1175 0, 20, 1164 0, 20,
1176 HTLEFT)); 1165 HTLEFT));
1177 DragMove(-kResizeSpan3, 0); 1166 DragMove(-kResizeSpan3, 0);
1178 DragEnd(); 1167 DragEnd();
1179 EXPECT_EQ(previous_width + kResizeSpan3, w1->bounds().width()); 1168 EXPECT_EQ(previous_width + kResizeSpan3, w1->bounds().width());
1180 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1169 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1181 // Docked area should be as wide as possible (maximum) and same as w1. 1170 // Docked area should be as wide as possible (maximum) and same as w1.
1182 EXPECT_EQ(max_width(), docked_width(manager)); 1171 EXPECT_EQ(max_width(), docked_width(manager));
1183 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1172 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1184 1173
1185 // Undock the first window. Docked area should shrink to its ideal size. 1174 // Undock the first window. Docked area should shrink to its ideal size.
1186 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); 1175 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get()));
1187 // Drag up as well to avoid attaching panels to launcher shelf. 1176 // Drag up as well to avoid attaching panels to launcher shelf.
1188 DragMove(-(400 - 210), -100); 1177 DragMove(-(400 - 210), -100);
1189 // Alignment set to "RIGHT" since we have another window docked. 1178 // Alignment set to "RIGHT" since we have another window docked.
1190 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1179 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1191 // Release the mouse and the window should be no longer attached to the edge. 1180 // Release the mouse and the window should be no longer attached to the edge.
1192 DragEnd(); 1181 DragEnd();
1193 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w1->parent()->id()); 1182 EXPECT_EQ(kShellWindowId_DefaultContainer, w1->parent()->id());
1194 // Dock should be as wide as w2 (and same as ideal width). 1183 // Dock should be as wide as w2 (and same as ideal width).
1195 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1184 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1196 EXPECT_EQ(ideal_width(), docked_width(manager)); 1185 EXPECT_EQ(ideal_width(), docked_width(manager));
1197 EXPECT_EQ(w2->bounds().width(), docked_width(manager)); 1186 EXPECT_EQ(w2->bounds().width(), docked_width(manager));
1198 // The second window should be still docked. 1187 // The second window should be still docked.
1199 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 1188 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
1200 // Desktop work area should be inset. 1189 // Desktop work area should be inset.
1201 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width() - 1190 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width() -
1202 docked_width(manager) - min_dock_gap(), 1191 docked_width(manager) - min_dock_gap(),
1203 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); 1192 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width());
1204 } 1193 }
1205 1194
1206 // Dock a window, resize it and test that undocking it preserves the width. 1195 // Dock a window, resize it and test that undocking it preserves the width.
1207 TEST_P(DockedWindowResizerTest, ResizingKeepsWidth) { 1196 TEST_P(DockedWindowResizerTest, ResizingKeepsWidth) {
1208 if (!SupportsHostWindowResize()) 1197 if (!SupportsHostWindowResize())
1209 return; 1198 return;
1210 1199
1211 // Wider display to start since panels are limited to half the display width. 1200 // Wider display to start since panels are limited to half the display width.
1212 UpdateDisplay("1000x600"); 1201 UpdateDisplay("1000x600");
1213 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1202 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1214 1203
1215 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1204 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1216 // Window should be docked at the right edge. 1205 // Window should be docked at the right edge.
1217 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 1206 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
1218 w1->GetBoundsInScreen().right()); 1207 w1->GetBoundsInScreen().right());
1219 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1208 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1220 DockedWindowLayoutManager* manager = 1209 DockedWindowLayoutManager* manager =
1221 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1210 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
1222 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1211 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1223 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1212 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1224 1213
1225 // Resize the window left by a bit and test that the dock expands. 1214 // Resize the window left by a bit and test that the dock expands.
1226 int previous_width = w1->bounds().width(); 1215 int previous_width = w1->bounds().width();
1227 const int kResizeSpan1 = 30; 1216 const int kResizeSpan1 = 30;
1228 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), 1217 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(),
1229 0, 20, 1218 0, 20,
1230 HTLEFT)); 1219 HTLEFT));
1231 DragMove(-kResizeSpan1, 0); 1220 DragMove(-kResizeSpan1, 0);
1232 // Alignment stays "RIGHT" during the drag because the only docked window 1221 // Alignment stays "RIGHT" during the drag because the only docked window
1233 // is being resized. 1222 // is being resized.
1234 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1223 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1235 // Release the mouse and the window should be attached to the edge. 1224 // Release the mouse and the window should be attached to the edge.
1236 DragEnd(); 1225 DragEnd();
1237 // The window should get docked. 1226 // The window should get docked.
1238 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1227 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1239 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1228 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1240 // w1 is now wider and the dock should expand to be as wide as w1. 1229 // w1 is now wider and the dock should expand to be as wide as w1.
1241 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width()); 1230 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width());
1242 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1231 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1243 1232
1244 // Undock by dragging almost to the left edge. 1233 // Undock by dragging almost to the left edge.
1245 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, w1.get(), 100, 20); 1234 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, w1.get(), 100, 20);
1246 // Width should be preserved. 1235 // Width should be preserved.
1247 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width()); 1236 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width());
1248 // Height should be restored to what it was originally. 1237 // Height should be restored to what it was originally.
(...skipping 18 matching lines...) Expand all
1267 return; 1256 return;
1268 1257
1269 // Wider display to start since panels are limited to half the display width. 1258 // Wider display to start since panels are limited to half the display width.
1270 UpdateDisplay("1000x600"); 1259 UpdateDisplay("1000x600");
1271 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1260 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1272 1261
1273 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1262 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1274 // Window should be docked at the right edge. 1263 // Window should be docked at the right edge.
1275 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 1264 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
1276 w1->GetBoundsInScreen().right()); 1265 w1->GetBoundsInScreen().right());
1277 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1266 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1278 DockedWindowLayoutManager* manager = 1267 DockedWindowLayoutManager* manager =
1279 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1268 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
1280 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1269 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1281 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1270 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1282 1271
1283 // Resize the window left by a bit and test that the dock expands. 1272 // Resize the window left by a bit and test that the dock expands.
1284 int previous_width = w1->bounds().width(); 1273 int previous_width = w1->bounds().width();
1285 const int kResizeSpan1 = 30; 1274 const int kResizeSpan1 = 30;
1286 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin( 1275 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(
1287 w1.get(), 0, 20, HTLEFT)); 1276 w1.get(), 0, 20, HTLEFT));
1288 DragMove(-kResizeSpan1, 0); 1277 DragMove(-kResizeSpan1, 0);
1289 // Normally alignment would be reset to "NONE" during the drag when there is 1278 // Normally alignment would be reset to "NONE" during the drag when there is
1290 // only a single window docked and it is being dragged. However because that 1279 // only a single window docked and it is being dragged. However because that
1291 // window is being resized rather than moved the alignment is not changed. 1280 // window is being resized rather than moved the alignment is not changed.
1292 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1281 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1293 // Release the mouse and the window should be attached to the edge. 1282 // Release the mouse and the window should be attached to the edge.
1294 DragEnd(); 1283 DragEnd();
1295 // The window should stay docked. 1284 // The window should stay docked.
1296 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1285 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1297 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1286 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1298 // w1 is now wider and the dock should expand to be as wide as w1. 1287 // w1 is now wider and the dock should expand to be as wide as w1.
1299 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width()); 1288 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width());
1300 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1289 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1301 1290
1302 // Resize the window by dragging its right edge left a bit and test that the 1291 // Resize the window by dragging its right edge left a bit and test that the
1303 // window stays docked. 1292 // window stays docked.
1304 previous_width = w1->bounds().width(); 1293 previous_width = w1->bounds().width();
1305 const int kResizeSpan2 = 15; 1294 const int kResizeSpan2 = 15;
1306 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin( 1295 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(
1307 w1.get(), w1->bounds().width(), 20, HTRIGHT)); 1296 w1.get(), w1->bounds().width(), 20, HTRIGHT));
1308 DragMove(-kResizeSpan2, 0); 1297 DragMove(-kResizeSpan2, 0);
1309 // Alignment stays "RIGHT" during the drag because the window is being 1298 // Alignment stays "RIGHT" during the drag because the window is being
1310 // resized rather than dragged. 1299 // resized rather than dragged.
1311 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1300 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1312 // Release the mouse and the window should be attached to the edge. 1301 // Release the mouse and the window should be attached to the edge.
1313 DragEnd(); 1302 DragEnd();
1314 // The window should stay docked. 1303 // The window should stay docked.
1315 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1304 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1316 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1305 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1317 // The dock should stay as wide as w1 is now (a bit less than before). 1306 // The dock should stay as wide as w1 is now (a bit less than before).
1318 EXPECT_EQ(previous_width - kResizeSpan2, w1->bounds().width()); 1307 EXPECT_EQ(previous_width - kResizeSpan2, w1->bounds().width());
1319 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1308 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1320 } 1309 }
1321 1310
1322 // Dock two windows, resize one. Test the docked windows area size. 1311 // Dock two windows, resize one. Test the docked windows area size.
1323 TEST_P(DockedWindowResizerTest, ResizeTwoWindows) { 1312 TEST_P(DockedWindowResizerTest, ResizeTwoWindows) {
1324 if (!SupportsHostWindowResize()) 1313 if (!SupportsHostWindowResize())
1325 return; 1314 return;
1326 1315
1327 // Wider display to start since panels are limited to half the display width. 1316 // Wider display to start since panels are limited to half the display width.
1328 UpdateDisplay("1000x600"); 1317 UpdateDisplay("1000x600");
1329 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1318 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1330 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); 1319 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201)));
1331 1320
1332 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1321 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1333 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); 1322 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100);
1334 // Both windows should now be docked at the right edge. 1323 // Both windows should now be docked at the right edge.
1335 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1324 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1336 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 1325 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
1337 // Dock width should be set to ideal width. 1326 // Dock width should be set to ideal width.
1338 DockedWindowLayoutManager* manager = 1327 DockedWindowLayoutManager* manager =
1339 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1328 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
1340 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1329 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1341 EXPECT_EQ(ideal_width(), docked_width(manager)); 1330 EXPECT_EQ(ideal_width(), docked_width(manager));
1342 1331
1343 // Resize the first window left by a bit and test that the dock expands. 1332 // Resize the first window left by a bit and test that the dock expands.
1344 int previous_width = w1->bounds().width(); 1333 int previous_width = w1->bounds().width();
1345 const int kResizeSpan1 = 30; 1334 const int kResizeSpan1 = 30;
1346 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), 1335 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(),
(...skipping 15 matching lines...) Expand all
1362 DragMove(-kResizeSpan1, 0); 1351 DragMove(-kResizeSpan1, 0);
1363 DragEnd(); 1352 DragEnd();
1364 // w2 should get wider since it was resized by a user. 1353 // w2 should get wider since it was resized by a user.
1365 EXPECT_EQ(previous_width + kResizeSpan1, w2->bounds().width()); 1354 EXPECT_EQ(previous_width + kResizeSpan1, w2->bounds().width());
1366 // w1 should stay as wide as w2 since both were flush with the dock edge. 1355 // w1 should stay as wide as w2 since both were flush with the dock edge.
1367 EXPECT_EQ(w2->bounds().width(), w1->bounds().width()); 1356 EXPECT_EQ(w2->bounds().width(), w1->bounds().width());
1368 EXPECT_EQ(w2->bounds().width(), docked_width(manager)); 1357 EXPECT_EQ(w2->bounds().width(), docked_width(manager));
1369 1358
1370 // Undock w2 and then dock it back. 1359 // Undock w2 and then dock it back.
1371 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_RIGHT, w2.get(), -400, 100); 1360 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_RIGHT, w2.get(), -400, 100);
1372 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 1361 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
1373 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); 1362 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100);
1374 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 1363 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
1375 // w2 should become same width as w1. 1364 // w2 should become same width as w1.
1376 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); 1365 EXPECT_EQ(w1->bounds().width(), w2->bounds().width());
1377 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1366 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1378 1367
1379 // Make w1 even wider. 1368 // Make w1 even wider.
1380 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), 1369 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(),
1381 0, 20, 1370 0, 20,
1382 HTLEFT)); 1371 HTLEFT));
1383 DragMove(-kResizeSpan1, 0); 1372 DragMove(-kResizeSpan1, 0);
1384 DragEnd(); 1373 DragEnd();
(...skipping 11 matching lines...) Expand all
1396 1385
1397 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1386 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1398 // Work area should cover the whole screen. 1387 // Work area should cover the whole screen.
1399 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(), 1388 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(),
1400 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); 1389 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width());
1401 1390
1402 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1391 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1403 // A window should be docked at the right edge. 1392 // A window should be docked at the right edge.
1404 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 1393 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
1405 w1->GetBoundsInScreen().right()); 1394 w1->GetBoundsInScreen().right());
1406 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1395 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1407 DockedWindowLayoutManager* manager = 1396 DockedWindowLayoutManager* manager =
1408 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1397 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
1409 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1398 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1410 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1399 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1411 1400
1412 // Detach and drag down to shelf. 1401 // Detach and drag down to shelf.
1413 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); 1402 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get()));
1414 DragMove(-40, 0); 1403 DragMove(-40, 0);
1415 // Alignment is set to "NONE" when drag starts. 1404 // Alignment is set to "NONE" when drag starts.
1416 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); 1405 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
(...skipping 29 matching lines...) Expand all
1446 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithDelegateAndType( 1435 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithDelegateAndType(
1447 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); 1436 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20)));
1448 ::wm::AddTransientChild(window.get(), child.get()); 1437 ::wm::AddTransientChild(window.get(), child.get());
1449 if (window->parent() != child->parent()) 1438 if (window->parent() != child->parent())
1450 window->parent()->AddChild(child.get()); 1439 window->parent()->AddChild(child.get());
1451 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); 1440 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get()));
1452 1441
1453 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); 1442 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20);
1454 1443
1455 // A window should be docked at the right edge. 1444 // A window should be docked at the right edge.
1456 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 1445 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
1457 EXPECT_EQ(internal::kShellWindowId_DockedContainer, child->parent()->id()); 1446 EXPECT_EQ(kShellWindowId_DockedContainer, child->parent()->id());
1458 1447
1459 // Drag the child - it should move freely and stay where it is dragged. 1448 // Drag the child - it should move freely and stay where it is dragged.
1460 ASSERT_NO_FATAL_FAILURE(DragStart(child.get())); 1449 ASSERT_NO_FATAL_FAILURE(DragStart(child.get()));
1461 DragMove(500, 20); 1450 DragMove(500, 20);
1462 DragEnd(); 1451 DragEnd();
1463 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(), 1452 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(),
1464 child->GetBoundsInScreen().origin().ToString()); 1453 child->GetBoundsInScreen().origin().ToString());
1465 1454
1466 // Undock the window by dragging left. 1455 // Undock the window by dragging left.
1467 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); 1456 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
1468 DragMove(-32, -10); 1457 DragMove(-32, -10);
1469 DragEnd(); 1458 DragEnd();
1470 1459
1471 // The window should be undocked and the transient child should be reparented. 1460 // The window should be undocked and the transient child should be reparented.
1472 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); 1461 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
1473 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, child->parent()->id()); 1462 EXPECT_EQ(kShellWindowId_DefaultContainer, child->parent()->id());
1474 // The child should not have moved. 1463 // The child should not have moved.
1475 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(), 1464 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(),
1476 child->GetBoundsInScreen().origin().ToString()); 1465 child->GetBoundsInScreen().origin().ToString());
1477 } 1466 }
1478 1467
1479 // Tests that reparenting windows during the drag does not affect system modal 1468 // Tests that reparenting windows during the drag does not affect system modal
1480 // windows that are transient children of the dragged windows. 1469 // windows that are transient children of the dragged windows.
1481 TEST_P(DockedWindowResizerTest, DragWindowWithModalTransientChild) { 1470 TEST_P(DockedWindowResizerTest, DragWindowWithModalTransientChild) {
1482 if (!SupportsHostWindowResize()) 1471 if (!SupportsHostWindowResize())
1483 return; 1472 return;
1484 1473
1485 // Create a window. 1474 // Create a window.
1486 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1475 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1487 gfx::Rect bounds(window->bounds()); 1476 gfx::Rect bounds(window->bounds());
1488 1477
1489 // Start dragging the window. 1478 // Start dragging the window.
1490 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); 1479 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
1491 gfx::Vector2d move_vector(40, test_panels() ? -60 : 60); 1480 gfx::Vector2d move_vector(40, test_panels() ? -60 : 60);
1492 DragMove(move_vector.x(), move_vector.y()); 1481 DragMove(move_vector.x(), move_vector.y());
1493 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 1482 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
1494 1483
1495 // While still dragging create a modal window and make it a transient child of 1484 // While still dragging create a modal window and make it a transient child of
1496 // the |window|. 1485 // the |window|.
1497 scoped_ptr<aura::Window> child(CreateModalWindow(gfx::Rect(20, 20, 150, 20))); 1486 scoped_ptr<aura::Window> child(CreateModalWindow(gfx::Rect(20, 20, 150, 20)));
1498 ::wm::AddTransientChild(window.get(), child.get()); 1487 ::wm::AddTransientChild(window.get(), child.get());
1499 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); 1488 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get()));
1500 EXPECT_EQ(internal::kShellWindowId_SystemModalContainer, 1489 EXPECT_EQ(kShellWindowId_SystemModalContainer, child->parent()->id());
1501 child->parent()->id());
1502 1490
1503 // End the drag, the |window| should have moved (if it is a panel it will 1491 // End the drag, the |window| should have moved (if it is a panel it will
1504 // no longer be attached to the shelf since we dragged it above). 1492 // no longer be attached to the shelf since we dragged it above).
1505 DragEnd(); 1493 DragEnd();
1506 bounds.Offset(move_vector); 1494 bounds.Offset(move_vector);
1507 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); 1495 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString());
1508 1496
1509 // The original |window| should be in the default container (not docked or 1497 // The original |window| should be in the default container (not docked or
1510 // attached). 1498 // attached).
1511 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); 1499 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
1512 // The transient |child| should still be in system modal container. 1500 // The transient |child| should still be in system modal container.
1513 EXPECT_EQ(internal::kShellWindowId_SystemModalContainer, 1501 EXPECT_EQ(kShellWindowId_SystemModalContainer, child->parent()->id());
1514 child->parent()->id());
1515 // The |child| should not have moved. 1502 // The |child| should not have moved.
1516 EXPECT_EQ(gfx::Point(20, 20).ToString(), 1503 EXPECT_EQ(gfx::Point(20, 20).ToString(),
1517 child->GetBoundsInScreen().origin().ToString()); 1504 child->GetBoundsInScreen().origin().ToString());
1518 // The |child| should still be a transient child of |window|. 1505 // The |child| should still be a transient child of |window|.
1519 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); 1506 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get()));
1520 } 1507 }
1521 1508
1522 // Tests that side snapping a window undocks it, closes the dock and then snaps. 1509 // Tests that side snapping a window undocks it, closes the dock and then snaps.
1523 TEST_P(DockedWindowResizerTest, SideSnapDocked) { 1510 TEST_P(DockedWindowResizerTest, SideSnapDocked) {
1524 if (!SupportsHostWindowResize() || test_panels()) 1511 if (!SupportsHostWindowResize() || test_panels())
1525 return; 1512 return;
1526 1513
1527 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1514 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1528 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 1515 wm::WindowState* window_state = wm::GetWindowState(w1.get());
1529 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1516 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1530 // A window should be docked at the right edge. 1517 // A window should be docked at the right edge.
1531 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 1518 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
1532 w1->GetBoundsInScreen().right()); 1519 w1->GetBoundsInScreen().right());
1533 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1520 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1534 DockedWindowLayoutManager* manager = 1521 DockedWindowLayoutManager* manager =
1535 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1522 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
1536 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1523 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1537 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1524 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1538 EXPECT_TRUE(window_state->IsDocked()); 1525 EXPECT_TRUE(window_state->IsDocked());
1539 EXPECT_FALSE(window_state->IsSnapped()); 1526 EXPECT_FALSE(window_state->IsSnapped());
1540 1527
1541 // Side snap at right edge. 1528 // Side snap at right edge.
1542 const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT); 1529 const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT);
1543 window_state->OnWMEvent(&snap_right); 1530 window_state->OnWMEvent(&snap_right);
1544 // The window should be snapped at the right edge and the dock should close. 1531 // The window should be snapped at the right edge and the dock should close.
1545 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get())); 1532 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()));
1546 EXPECT_EQ(0, docked_width(manager)); 1533 EXPECT_EQ(0, docked_width(manager));
1547 EXPECT_EQ(work_area.height(), w1->bounds().height()); 1534 EXPECT_EQ(work_area.height(), w1->bounds().height());
1548 EXPECT_EQ(work_area.right(), w1->bounds().right()); 1535 EXPECT_EQ(work_area.right(), w1->bounds().right());
1549 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w1->parent()->id()); 1536 EXPECT_EQ(kShellWindowId_DefaultContainer, w1->parent()->id());
1550 EXPECT_FALSE(window_state->IsDocked()); 1537 EXPECT_FALSE(window_state->IsDocked());
1551 EXPECT_TRUE(window_state->IsSnapped()); 1538 EXPECT_TRUE(window_state->IsSnapped());
1552 1539
1553 // Dock again. 1540 // Dock again.
1554 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1541 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1555 // A window should be docked at the right edge. 1542 // A window should be docked at the right edge.
1556 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 1543 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
1557 w1->GetBoundsInScreen().right()); 1544 w1->GetBoundsInScreen().right());
1558 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1545 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1559 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1546 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1560 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1547 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1561 EXPECT_TRUE(window_state->IsDocked()); 1548 EXPECT_TRUE(window_state->IsDocked());
1562 EXPECT_FALSE(window_state->IsSnapped()); 1549 EXPECT_FALSE(window_state->IsSnapped());
1563 1550
1564 // Side snap at left edge. 1551 // Side snap at left edge.
1565 const wm::WMEvent snap_left(wm::WM_EVENT_SNAP_LEFT); 1552 const wm::WMEvent snap_left(wm::WM_EVENT_SNAP_LEFT);
1566 window_state->OnWMEvent(&snap_left); 1553 window_state->OnWMEvent(&snap_left);
1567 // The window should be snapped at the right edge and the dock should close. 1554 // The window should be snapped at the right edge and the dock should close.
1568 EXPECT_EQ(work_area.ToString(), 1555 EXPECT_EQ(work_area.ToString(),
1569 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).ToString()); 1556 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).ToString());
1570 EXPECT_EQ(0, docked_width(manager)); 1557 EXPECT_EQ(0, docked_width(manager));
1571 EXPECT_EQ(work_area.height(), w1->bounds().height()); 1558 EXPECT_EQ(work_area.height(), w1->bounds().height());
1572 EXPECT_EQ(work_area.x(), w1->bounds().x()); 1559 EXPECT_EQ(work_area.x(), w1->bounds().x());
1573 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w1->parent()->id()); 1560 EXPECT_EQ(kShellWindowId_DefaultContainer, w1->parent()->id());
1574 EXPECT_FALSE(window_state->IsDocked()); 1561 EXPECT_FALSE(window_state->IsDocked());
1575 EXPECT_TRUE(window_state->IsSnapped()); 1562 EXPECT_TRUE(window_state->IsSnapped());
1576 } 1563 }
1577 1564
1578 // Tests that a window is undocked if the window is maximized via a keyboard 1565 // Tests that a window is undocked if the window is maximized via a keyboard
1579 // accelerator during a drag. 1566 // accelerator during a drag.
1580 TEST_P(DockedWindowResizerTest, MaximizedDuringDrag) { 1567 TEST_P(DockedWindowResizerTest, MaximizedDuringDrag) {
1581 if (!SupportsHostWindowResize() || test_panels()) 1568 if (!SupportsHostWindowResize() || test_panels())
1582 return; 1569 return;
1583 1570
1584 scoped_ptr<aura::Window> window(CreateTestWindow( 1571 scoped_ptr<aura::Window> window(CreateTestWindow(
1585 gfx::Rect(0, 0, ideal_width(), 201))); 1572 gfx::Rect(0, 0, ideal_width(), 201)));
1586 wm::WindowState* window_state = wm::GetWindowState(window.get()); 1573 wm::WindowState* window_state = wm::GetWindowState(window.get());
1587 1574
1588 // Dock the window to the right edge. 1575 // Dock the window to the right edge.
1589 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); 1576 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20);
1590 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 1577 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
1591 window->GetBoundsInScreen().right()); 1578 window->GetBoundsInScreen().right());
1592 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 1579 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
1593 DockedWindowLayoutManager* manager = 1580 DockedWindowLayoutManager* manager =
1594 static_cast<DockedWindowLayoutManager*>( 1581 static_cast<DockedWindowLayoutManager*>(
1595 window->parent()->layout_manager()); 1582 window->parent()->layout_manager());
1596 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1583 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1597 EXPECT_EQ(window->bounds().width(), docked_width(manager)); 1584 EXPECT_EQ(window->bounds().width(), docked_width(manager));
1598 EXPECT_TRUE(window_state->IsDocked()); 1585 EXPECT_TRUE(window_state->IsDocked());
1599 1586
1600 // Maximize the window while in a real drag. In particular, 1587 // Maximize the window while in a real drag. In particular,
1601 // ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowStateTypeChanged() 1588 // ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowStateTypeChanged()
1602 // must be called in order for the maximized window's size to be correct. 1589 // must be called in order for the maximized window's size to be correct.
1603 delegate()->set_window_component(HTCAPTION); 1590 delegate()->set_window_component(HTCAPTION);
1604 aura::test::EventGenerator& generator = GetEventGenerator(); 1591 aura::test::EventGenerator& generator = GetEventGenerator();
1605 generator.MoveMouseTo(window->GetBoundsInScreen().origin()); 1592 generator.MoveMouseTo(window->GetBoundsInScreen().origin());
1606 generator.PressLeftButton(); 1593 generator.PressLeftButton();
1607 generator.MoveMouseBy(10, 10); 1594 generator.MoveMouseBy(10, 10);
1608 window_state->Maximize(); 1595 window_state->Maximize();
1609 generator.ReleaseLeftButton(); 1596 generator.ReleaseLeftButton();
1610 1597
1611 // |window| should get undocked. 1598 // |window| should get undocked.
1612 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); 1599 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
1613 EXPECT_EQ(0, docked_width(manager)); 1600 EXPECT_EQ(0, docked_width(manager));
1614 EXPECT_EQ( 1601 EXPECT_EQ(
1615 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), 1602 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
1616 window->bounds().ToString()); 1603 window->bounds().ToString());
1617 EXPECT_TRUE(window_state->IsMaximized()); 1604 EXPECT_TRUE(window_state->IsMaximized());
1618 } 1605 }
1619 1606
1620 // Tests run twice - on both panels and normal windows 1607 // Tests run twice - on both panels and normal windows
1621 INSTANTIATE_TEST_CASE_P(NormalOrPanel, 1608 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
1622 DockedWindowResizerTest, 1609 DockedWindowResizerTest,
1623 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, 1610 testing::Values(ui::wm::WINDOW_TYPE_NORMAL,
1624 ui::wm::WINDOW_TYPE_PANEL)); 1611 ui::wm::WINDOW_TYPE_PANEL));
1625 } // namespace internal 1612
1626 } // namespace ash 1613 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/dock/docked_window_resizer.cc ('k') | ash/wm/drag_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698