| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/dock/docked_window_layout_manager.h" | 5 #include "ash/wm/dock/docked_window_layout_manager.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/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // Detach if our window is a panel, then drag it vertically by |dy| and | 179 // Detach if our window is a panel, then drag it vertically by |dy| and |
| 180 // horizontally to the edge with an added offset from the edge of |dx|. | 180 // horizontally to the edge with an added offset from the edge of |dx|. |
| 181 void DragVerticallyAndRelativeToEdge(DockedEdge edge, | 181 void DragVerticallyAndRelativeToEdge(DockedEdge edge, |
| 182 aura::Window* window, | 182 aura::Window* window, |
| 183 int dx, int dy) { | 183 int dx, int dy) { |
| 184 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 184 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 185 // avoid snap by clicking away from the border | 185 // avoid snap by clicking away from the border |
| 186 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5)); | 186 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5)); |
| 187 | 187 |
| 188 gfx::Rect work_area = | 188 gfx::Rect work_area = |
| 189 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); | 189 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area(); |
| 190 gfx::Point initial_location_in_screen = initial_location_in_parent_; | 190 gfx::Point initial_location_in_screen = initial_location_in_parent_; |
| 191 ::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen); | 191 ::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen); |
| 192 // Drag the window left or right to the edge (or almost to it). | 192 // Drag the window left or right to the edge (or almost to it). |
| 193 if (edge == DOCKED_EDGE_LEFT) | 193 if (edge == DOCKED_EDGE_LEFT) |
| 194 dx += work_area.x() - initial_location_in_screen.x(); | 194 dx += work_area.x() - initial_location_in_screen.x(); |
| 195 else if (edge == DOCKED_EDGE_RIGHT) | 195 else if (edge == DOCKED_EDGE_RIGHT) |
| 196 dx += work_area.right() - 1 - initial_location_in_screen.x(); | 196 dx += work_area.right() - 1 - initial_location_in_screen.x(); |
| 197 DragMove(dx, dy); | 197 DragMove(dx, dy); |
| 198 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 198 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
| 199 // Release the mouse and the panel should be attached to the dock. | 199 // Release the mouse and the panel should be attached to the dock. |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 // The windows should be attached and snapped to the right side of the screen. | 421 // The windows should be attached and snapped to the right side of the screen. |
| 422 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 422 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
| 423 w1->GetBoundsInScreen().right()); | 423 w1->GetBoundsInScreen().right()); |
| 424 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 424 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 425 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 425 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 426 w2->GetBoundsInScreen().right()); | 426 w2->GetBoundsInScreen().right()); |
| 427 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 427 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 428 | 428 |
| 429 // Test that the gaps differ at most by a single pixel. | 429 // Test that the gaps differ at most by a single pixel. |
| 430 gfx::Rect work_area = | 430 gfx::Rect work_area = |
| 431 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 431 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 432 int gap1 = w1->GetBoundsInScreen().y(); | 432 int gap1 = w1->GetBoundsInScreen().y(); |
| 433 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); | 433 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); |
| 434 int gap3 = work_area.bottom() - w2->GetBoundsInScreen().bottom(); | 434 int gap3 = work_area.bottom() - w2->GetBoundsInScreen().bottom(); |
| 435 EXPECT_EQ(0, gap1); | 435 EXPECT_EQ(0, gap1); |
| 436 EXPECT_NEAR(gap2, min_dock_gap(), 1); | 436 EXPECT_NEAR(gap2, min_dock_gap(), 1); |
| 437 EXPECT_EQ(0, gap3); | 437 EXPECT_EQ(0, gap3); |
| 438 } | 438 } |
| 439 | 439 |
| 440 // Adds two non-overlapping windows and tests layout after a drag. | 440 // Adds two non-overlapping windows and tests layout after a drag. |
| 441 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsDragging) { | 441 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsDragging) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 455 w2->GetBoundsInScreen().right()); | 455 w2->GetBoundsInScreen().right()); |
| 456 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 456 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 457 | 457 |
| 458 // Drag w2 above w1. | 458 // Drag w2 above w1. |
| 459 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w2.get(), 0, 20)); | 459 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w2.get(), 0, 20)); |
| 460 DragMove(0, -w2->bounds().height() / 2 - min_dock_gap() - 1); | 460 DragMove(0, -w2->bounds().height() / 2 - min_dock_gap() - 1); |
| 461 DragEnd(); | 461 DragEnd(); |
| 462 | 462 |
| 463 // Test the new windows order and that the gaps differ at most by a pixel. | 463 // Test the new windows order and that the gaps differ at most by a pixel. |
| 464 gfx::Rect work_area = | 464 gfx::Rect work_area = |
| 465 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 465 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 466 int gap1 = w2->GetBoundsInScreen().y() - work_area.y(); | 466 int gap1 = w2->GetBoundsInScreen().y() - work_area.y(); |
| 467 int gap2 = w1->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); | 467 int gap2 = w1->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); |
| 468 int gap3 = work_area.bottom() - w1->GetBoundsInScreen().bottom(); | 468 int gap3 = work_area.bottom() - w1->GetBoundsInScreen().bottom(); |
| 469 EXPECT_EQ(0, gap1); | 469 EXPECT_EQ(0, gap1); |
| 470 EXPECT_NEAR(gap2, min_dock_gap(), 1); | 470 EXPECT_NEAR(gap2, min_dock_gap(), 1); |
| 471 EXPECT_EQ(0, gap3); | 471 EXPECT_EQ(0, gap3); |
| 472 } | 472 } |
| 473 | 473 |
| 474 // Adds three overlapping windows and tests layout after a drag. | 474 // Adds three overlapping windows and tests layout after a drag. |
| 475 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDragging) { | 475 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDragging) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 491 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 491 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 492 w2->GetBoundsInScreen().right()); | 492 w2->GetBoundsInScreen().right()); |
| 493 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 493 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 494 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), | 494 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), |
| 495 w3->GetBoundsInScreen().right()); | 495 w3->GetBoundsInScreen().right()); |
| 496 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); | 496 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); |
| 497 | 497 |
| 498 // Test that the top and bottom windows are clamped in work area and | 498 // Test that the top and bottom windows are clamped in work area and |
| 499 // that the gaps between the windows differ at most by a pixel. | 499 // that the gaps between the windows differ at most by a pixel. |
| 500 gfx::Rect work_area = | 500 gfx::Rect work_area = |
| 501 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 501 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 502 int gap1 = w1->GetBoundsInScreen().y() - work_area.y(); | 502 int gap1 = w1->GetBoundsInScreen().y() - work_area.y(); |
| 503 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); | 503 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); |
| 504 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); | 504 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); |
| 505 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); | 505 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); |
| 506 EXPECT_EQ(0, gap1); | 506 EXPECT_EQ(0, gap1); |
| 507 EXPECT_NEAR(gap2, min_dock_gap(), 1); | 507 EXPECT_NEAR(gap2, min_dock_gap(), 1); |
| 508 EXPECT_NEAR(gap3, min_dock_gap(), 1); | 508 EXPECT_NEAR(gap3, min_dock_gap(), 1); |
| 509 EXPECT_EQ(0, gap4); | 509 EXPECT_EQ(0, gap4); |
| 510 | 510 |
| 511 // Drag w1 below the point where w1 and w2 would swap places. This point is | 511 // Drag w1 below the point where w1 and w2 would swap places. This point is |
| (...skipping 23 matching lines...) Expand all Loading... |
| 535 | 535 |
| 536 // Adds three windows in bottom display and tests layout after a drag. | 536 // Adds three windows in bottom display and tests layout after a drag. |
| 537 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDraggingSecondScreen) { | 537 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDraggingSecondScreen) { |
| 538 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) | 538 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) |
| 539 return; | 539 return; |
| 540 | 540 |
| 541 // Create two screen vertical layout. | 541 // Create two screen vertical layout. |
| 542 UpdateDisplay("600x1000,600x1000"); | 542 UpdateDisplay("600x1000,600x1000"); |
| 543 // Layout the secondary display to the bottom of the primary. | 543 // Layout the secondary display to the bottom of the primary. |
| 544 DisplayLayout layout(DisplayLayout::BOTTOM, 0); | 544 DisplayLayout layout(DisplayLayout::BOTTOM, 0); |
| 545 ASSERT_GT(Shell::GetScreen()->GetNumDisplays(), 1); | 545 ASSERT_GT(gfx::Screen::GetScreen()->GetNumDisplays(), 1); |
| 546 Shell::GetInstance()->display_manager()-> | 546 Shell::GetInstance()->display_manager()-> |
| 547 SetLayoutForCurrentDisplays(layout); | 547 SetLayoutForCurrentDisplays(layout); |
| 548 | 548 |
| 549 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 1000, 201, 310))); | 549 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 1000, 201, 310))); |
| 550 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 1000 + 20); | 550 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 1000 + 20); |
| 551 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 1000, 210, 310))); | 551 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 1000, 210, 310))); |
| 552 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 1000 + 500); | 552 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 1000 + 500); |
| 553 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 1000, 220, 310))); | 553 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 1000, 220, 310))); |
| 554 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 1000 + 600); | 554 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 1000 + 600); |
| 555 | 555 |
| 556 // All windows should be attached and snapped to the right side of the screen. | 556 // All windows should be attached and snapped to the right side of the screen. |
| 557 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 557 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
| 558 w1->GetBoundsInScreen().right()); | 558 w1->GetBoundsInScreen().right()); |
| 559 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 559 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 560 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 560 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 561 w2->GetBoundsInScreen().right()); | 561 w2->GetBoundsInScreen().right()); |
| 562 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 562 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 563 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), | 563 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), |
| 564 w3->GetBoundsInScreen().right()); | 564 w3->GetBoundsInScreen().right()); |
| 565 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); | 565 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); |
| 566 | 566 |
| 567 gfx::Rect work_area = | 567 gfx::Rect work_area = |
| 568 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 568 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 569 // Test that the top and bottom windows are clamped in work area and | 569 // Test that the top and bottom windows are clamped in work area and |
| 570 // that the overlaps between the windows differ at most by a pixel. | 570 // that the overlaps between the windows differ at most by a pixel. |
| 571 int gap1 = w1->GetBoundsInScreen().y() - work_area.y(); | 571 int gap1 = w1->GetBoundsInScreen().y() - work_area.y(); |
| 572 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); | 572 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); |
| 573 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); | 573 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); |
| 574 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); | 574 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); |
| 575 EXPECT_EQ(0, gap1); | 575 EXPECT_EQ(0, gap1); |
| 576 EXPECT_NEAR(gap2, min_dock_gap(), 1); | 576 EXPECT_NEAR(gap2, min_dock_gap(), 1); |
| 577 EXPECT_NEAR(gap3, min_dock_gap(), 1); | 577 EXPECT_NEAR(gap3, min_dock_gap(), 1); |
| 578 EXPECT_EQ(0, gap4); | 578 EXPECT_EQ(0, gap4); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 // The two windows should be attached and snapped to the right edge. | 754 // The two windows should be attached and snapped to the right edge. |
| 755 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 755 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
| 756 w1->GetBoundsInScreen().right()); | 756 w1->GetBoundsInScreen().right()); |
| 757 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 757 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 758 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 758 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 759 w2->GetBoundsInScreen().right()); | 759 w2->GetBoundsInScreen().right()); |
| 760 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 760 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 761 | 761 |
| 762 // The two windows should be same size vertically and almost 1/2 of work area. | 762 // The two windows should be same size vertically and almost 1/2 of work area. |
| 763 gfx::Rect work_area = | 763 gfx::Rect work_area = |
| 764 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 764 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 765 EXPECT_NEAR(w1->GetBoundsInScreen().height(), | 765 EXPECT_NEAR(w1->GetBoundsInScreen().height(), |
| 766 w2->GetBoundsInScreen().height(), | 766 w2->GetBoundsInScreen().height(), |
| 767 1); | 767 1); |
| 768 EXPECT_NEAR(work_area.height() / 2, w1->GetBoundsInScreen().height(), | 768 EXPECT_NEAR(work_area.height() / 2, w1->GetBoundsInScreen().height(), |
| 769 min_dock_gap() * 2); | 769 min_dock_gap() * 2); |
| 770 | 770 |
| 771 // Create and dock the third window. | 771 // Create and dock the third window. |
| 772 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); | 772 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); |
| 773 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); | 773 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); |
| 774 | 774 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 w2->GetBoundsInScreen().right()); | 816 w2->GetBoundsInScreen().right()); |
| 817 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 817 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 818 | 818 |
| 819 // The two windows should have their heights restricted. | 819 // The two windows should have their heights restricted. |
| 820 EXPECT_EQ(300, w1->GetBoundsInScreen().height()); | 820 EXPECT_EQ(300, w1->GetBoundsInScreen().height()); |
| 821 EXPECT_EQ(100, w2->GetBoundsInScreen().height()); | 821 EXPECT_EQ(100, w2->GetBoundsInScreen().height()); |
| 822 | 822 |
| 823 // w1 should be more than half of the work area height (even with a margin). | 823 // w1 should be more than half of the work area height (even with a margin). |
| 824 // w2 should be less than half of the work area height (even with a margin). | 824 // w2 should be less than half of the work area height (even with a margin). |
| 825 gfx::Rect work_area = | 825 gfx::Rect work_area = |
| 826 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 826 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 827 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10); | 827 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10); |
| 828 EXPECT_LT(w2->GetBoundsInScreen().height(), work_area.height() / 2 - 10); | 828 EXPECT_LT(w2->GetBoundsInScreen().height(), work_area.height() / 2 - 10); |
| 829 } | 829 } |
| 830 | 830 |
| 831 // Tests that a docked window is moved to primary display when secondary display | 831 // Tests that a docked window is moved to primary display when secondary display |
| 832 // is disconnected and that it stays docked and properly positioned. | 832 // is disconnected and that it stays docked and properly positioned. |
| 833 TEST_P(DockedWindowLayoutManagerTest, DisplayDisconnectionMovesDocked) { | 833 TEST_P(DockedWindowLayoutManagerTest, DisplayDisconnectionMovesDocked) { |
| 834 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) | 834 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) |
| 835 return; | 835 return; |
| 836 | 836 |
| 837 // Create a dual screen layout. | 837 // Create a dual screen layout. |
| 838 UpdateDisplay("600x700,800x600"); | 838 UpdateDisplay("600x700,800x600"); |
| 839 | 839 |
| 840 gfx::Rect bounds(600, 0, 201, 201); | 840 gfx::Rect bounds(600, 0, 201, 201); |
| 841 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 841 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 842 // Drag pointer to the right edge of the second screen. | 842 // Drag pointer to the right edge of the second screen. |
| 843 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 843 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
| 844 | 844 |
| 845 // Simulate disconnection of the secondary display. | 845 // Simulate disconnection of the secondary display. |
| 846 UpdateDisplay("600x700"); | 846 UpdateDisplay("600x700"); |
| 847 | 847 |
| 848 // The window should be still docked at the right edge. | 848 // The window should be still docked at the right edge. |
| 849 // Its height should grow to match the new work area. | 849 // Its height should grow to match the new work area. |
| 850 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 850 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
| 851 window->GetBoundsInScreen().right()); | 851 window->GetBoundsInScreen().right()); |
| 852 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 852 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 853 EXPECT_EQ(ideal_width(), window->bounds().width()); | 853 EXPECT_EQ(ideal_width(), window->bounds().width()); |
| 854 gfx::Rect work_area = | 854 gfx::Rect work_area = gfx::Screen::GetScreen() |
| 855 Shell::GetScreen()->GetDisplayNearestWindow(window.get()).work_area(); | 855 ->GetDisplayNearestWindow(window.get()) |
| 856 .work_area(); |
| 856 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); | 857 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); |
| 857 } | 858 } |
| 858 | 859 |
| 859 // Tests run twice - on both panels and normal windows | 860 // Tests run twice - on both panels and normal windows |
| 860 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 861 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
| 861 DockedWindowLayoutManagerTest, | 862 DockedWindowLayoutManagerTest, |
| 862 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 863 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 863 ui::wm::WINDOW_TYPE_PANEL)); | 864 ui::wm::WINDOW_TYPE_PANEL)); |
| 864 | 865 |
| 865 } // namespace ash | 866 } // namespace ash |
| OLD | NEW |