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

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

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « ash/wm/common/wm_window.h ('k') | ash/wm/dock/docked_window_resizer.cc » ('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/common/dock/docked_window_layout_manager.h" 5 #include "ash/wm/common/dock/docked_window_layout_manager.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shelf/shelf.h" 10 #include "ash/shelf/shelf.h"
(...skipping 16 matching lines...) Expand all
27 #include "ash/wm/window_state_aura.h" 27 #include "ash/wm/window_state_aura.h"
28 #include "ash/wm/window_util.h" 28 #include "ash/wm/window_util.h"
29 #include "base/command_line.h" 29 #include "base/command_line.h"
30 #include "base/strings/string_number_conversions.h" 30 #include "base/strings/string_number_conversions.h"
31 #include "ui/aura/client/aura_constants.h" 31 #include "ui/aura/client/aura_constants.h"
32 #include "ui/aura/test/test_window_delegate.h" 32 #include "ui/aura/test/test_window_delegate.h"
33 #include "ui/aura/window.h" 33 #include "ui/aura/window.h"
34 #include "ui/aura/window_event_dispatcher.h" 34 #include "ui/aura/window_event_dispatcher.h"
35 #include "ui/base/hit_test.h" 35 #include "ui/base/hit_test.h"
36 #include "ui/display/manager/display_layout.h" 36 #include "ui/display/manager/display_layout.h"
37 #include "ui/gfx/screen.h" 37 #include "ui/display/screen.h"
38 #include "ui/views/widget/widget.h" 38 #include "ui/views/widget/widget.h"
39 #include "ui/wm/core/coordinate_conversion.h" 39 #include "ui/wm/core/coordinate_conversion.h"
40 40
41 namespace ash { 41 namespace ash {
42 42
43 class DockedWindowLayoutManagerTest 43 class DockedWindowLayoutManagerTest
44 : public test::AshTestBase, 44 : public test::AshTestBase,
45 public testing::WithParamInterface<ui::wm::WindowType> { 45 public testing::WithParamInterface<ui::wm::WindowType> {
46 public: 46 public:
47 DockedWindowLayoutManagerTest() : window_type_(GetParam()) {} 47 DockedWindowLayoutManagerTest() : window_type_(GetParam()) {}
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 // Detach if our window is a panel, then drag it vertically by |dy| and 175 // Detach if our window is a panel, then drag it vertically by |dy| and
176 // horizontally to the edge with an added offset from the edge of |dx|. 176 // horizontally to the edge with an added offset from the edge of |dx|.
177 void DragVerticallyAndRelativeToEdge(DockedEdge edge, 177 void DragVerticallyAndRelativeToEdge(DockedEdge edge,
178 aura::Window* window, 178 aura::Window* window,
179 int dx, int dy) { 179 int dx, int dy) {
180 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 180 gfx::Rect initial_bounds = window->GetBoundsInScreen();
181 // avoid snap by clicking away from the border 181 // avoid snap by clicking away from the border
182 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5)); 182 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5));
183 183
184 gfx::Rect work_area = 184 gfx::Rect work_area = display::Screen::GetScreen()
185 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area(); 185 ->GetDisplayNearestWindow(window)
186 .work_area();
186 gfx::Point initial_location_in_screen = initial_location_in_parent_; 187 gfx::Point initial_location_in_screen = initial_location_in_parent_;
187 ::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen); 188 ::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen);
188 // Drag the window left or right to the edge (or almost to it). 189 // Drag the window left or right to the edge (or almost to it).
189 if (edge == DOCKED_EDGE_LEFT) 190 if (edge == DOCKED_EDGE_LEFT)
190 dx += work_area.x() - initial_location_in_screen.x(); 191 dx += work_area.x() - initial_location_in_screen.x();
191 else if (edge == DOCKED_EDGE_RIGHT) 192 else if (edge == DOCKED_EDGE_RIGHT)
192 dx += work_area.right() - 1 - initial_location_in_screen.x(); 193 dx += work_area.right() - 1 - initial_location_in_screen.x();
193 DragMove(dx, dy); 194 DragMove(dx, dy);
194 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 195 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
195 // Release the mouse and the panel should be attached to the dock. 196 // Release the mouse and the panel should be attached to the dock.
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 417
417 // The windows should be attached and snapped to the right side of the screen. 418 // The windows should be attached and snapped to the right side of the screen.
418 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), 419 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
419 w1->GetBoundsInScreen().right()); 420 w1->GetBoundsInScreen().right());
420 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 421 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
421 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), 422 EXPECT_EQ(w2->GetRootWindow()->bounds().right(),
422 w2->GetBoundsInScreen().right()); 423 w2->GetBoundsInScreen().right());
423 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); 424 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
424 425
425 // Test that the gaps differ at most by a single pixel. 426 // Test that the gaps differ at most by a single pixel.
426 gfx::Rect work_area = 427 gfx::Rect work_area = display::Screen::GetScreen()
427 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); 428 ->GetDisplayNearestWindow(w1.get())
429 .work_area();
428 int gap1 = w1->GetBoundsInScreen().y(); 430 int gap1 = w1->GetBoundsInScreen().y();
429 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); 431 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom();
430 int gap3 = work_area.bottom() - w2->GetBoundsInScreen().bottom(); 432 int gap3 = work_area.bottom() - w2->GetBoundsInScreen().bottom();
431 EXPECT_EQ(0, gap1); 433 EXPECT_EQ(0, gap1);
432 EXPECT_NEAR(gap2, min_dock_gap(), 1); 434 EXPECT_NEAR(gap2, min_dock_gap(), 1);
433 EXPECT_EQ(0, gap3); 435 EXPECT_EQ(0, gap3);
434 } 436 }
435 437
436 // Adds two non-overlapping windows and tests layout after a drag. 438 // Adds two non-overlapping windows and tests layout after a drag.
437 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsDragging) { 439 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsDragging) {
(...skipping 12 matching lines...) Expand all
450 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), 452 EXPECT_EQ(w2->GetRootWindow()->bounds().right(),
451 w2->GetBoundsInScreen().right()); 453 w2->GetBoundsInScreen().right());
452 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); 454 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
453 455
454 // Drag w2 above w1. 456 // Drag w2 above w1.
455 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w2.get(), 0, 20)); 457 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w2.get(), 0, 20));
456 DragMove(0, -w2->bounds().height() / 2 - min_dock_gap() - 1); 458 DragMove(0, -w2->bounds().height() / 2 - min_dock_gap() - 1);
457 DragEnd(); 459 DragEnd();
458 460
459 // Test the new windows order and that the gaps differ at most by a pixel. 461 // Test the new windows order and that the gaps differ at most by a pixel.
460 gfx::Rect work_area = 462 gfx::Rect work_area = display::Screen::GetScreen()
461 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); 463 ->GetDisplayNearestWindow(w1.get())
464 .work_area();
462 int gap1 = w2->GetBoundsInScreen().y() - work_area.y(); 465 int gap1 = w2->GetBoundsInScreen().y() - work_area.y();
463 int gap2 = w1->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); 466 int gap2 = w1->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom();
464 int gap3 = work_area.bottom() - w1->GetBoundsInScreen().bottom(); 467 int gap3 = work_area.bottom() - w1->GetBoundsInScreen().bottom();
465 EXPECT_EQ(0, gap1); 468 EXPECT_EQ(0, gap1);
466 EXPECT_NEAR(gap2, min_dock_gap(), 1); 469 EXPECT_NEAR(gap2, min_dock_gap(), 1);
467 EXPECT_EQ(0, gap3); 470 EXPECT_EQ(0, gap3);
468 } 471 }
469 472
470 // Adds three overlapping windows and tests layout after a drag. 473 // Adds three overlapping windows and tests layout after a drag.
471 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDragging) { 474 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDragging) {
(...skipping 14 matching lines...) Expand all
486 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 489 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
487 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), 490 EXPECT_EQ(w2->GetRootWindow()->bounds().right(),
488 w2->GetBoundsInScreen().right()); 491 w2->GetBoundsInScreen().right());
489 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); 492 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
490 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), 493 EXPECT_EQ(w3->GetRootWindow()->bounds().right(),
491 w3->GetBoundsInScreen().right()); 494 w3->GetBoundsInScreen().right());
492 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); 495 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id());
493 496
494 // Test that the top and bottom windows are clamped in work area and 497 // Test that the top and bottom windows are clamped in work area and
495 // that the gaps between the windows differ at most by a pixel. 498 // that the gaps between the windows differ at most by a pixel.
496 gfx::Rect work_area = 499 gfx::Rect work_area = display::Screen::GetScreen()
497 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); 500 ->GetDisplayNearestWindow(w1.get())
501 .work_area();
498 int gap1 = w1->GetBoundsInScreen().y() - work_area.y(); 502 int gap1 = w1->GetBoundsInScreen().y() - work_area.y();
499 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); 503 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom();
500 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); 504 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom();
501 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); 505 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom();
502 EXPECT_EQ(0, gap1); 506 EXPECT_EQ(0, gap1);
503 EXPECT_NEAR(gap2, min_dock_gap(), 1); 507 EXPECT_NEAR(gap2, min_dock_gap(), 1);
504 EXPECT_NEAR(gap3, min_dock_gap(), 1); 508 EXPECT_NEAR(gap3, min_dock_gap(), 1);
505 EXPECT_EQ(0, gap4); 509 EXPECT_EQ(0, gap4);
506 510
507 // 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 22 matching lines...) Expand all
530 } 534 }
531 535
532 // 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.
533 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDraggingSecondScreen) { 537 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDraggingSecondScreen) {
534 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) 538 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize())
535 return; 539 return;
536 540
537 // Create two screen vertical layout. 541 // Create two screen vertical layout.
538 UpdateDisplay("600x1000,600x1000"); 542 UpdateDisplay("600x1000,600x1000");
539 // Layout the secondary display to the bottom of the primary. 543 // Layout the secondary display to the bottom of the primary.
540 ASSERT_GT(gfx::Screen::GetScreen()->GetNumDisplays(), 1); 544 ASSERT_GT(display::Screen::GetScreen()->GetNumDisplays(), 1);
541 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 545 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
542 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 0)); 546 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 0));
543 547
544 std::unique_ptr<aura::Window> w1( 548 std::unique_ptr<aura::Window> w1(
545 CreateTestWindow(gfx::Rect(0, 1000, 201, 310))); 549 CreateTestWindow(gfx::Rect(0, 1000, 201, 310)));
546 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 1000 + 20); 550 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 1000 + 20);
547 std::unique_ptr<aura::Window> w2( 551 std::unique_ptr<aura::Window> w2(
548 CreateTestWindow(gfx::Rect(0, 1000, 210, 310))); 552 CreateTestWindow(gfx::Rect(0, 1000, 210, 310)));
549 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 1000 + 500); 553 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 1000 + 500);
550 std::unique_ptr<aura::Window> w3( 554 std::unique_ptr<aura::Window> w3(
551 CreateTestWindow(gfx::Rect(0, 1000, 220, 310))); 555 CreateTestWindow(gfx::Rect(0, 1000, 220, 310)));
552 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 1000 + 600); 556 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 1000 + 600);
553 557
554 // All windows should be attached and snapped to the right side of the screen. 558 // All windows should be attached and snapped to the right side of the screen.
555 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), 559 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
556 w1->GetBoundsInScreen().right()); 560 w1->GetBoundsInScreen().right());
557 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 561 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
558 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), 562 EXPECT_EQ(w2->GetRootWindow()->bounds().right(),
559 w2->GetBoundsInScreen().right()); 563 w2->GetBoundsInScreen().right());
560 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); 564 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
561 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), 565 EXPECT_EQ(w3->GetRootWindow()->bounds().right(),
562 w3->GetBoundsInScreen().right()); 566 w3->GetBoundsInScreen().right());
563 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); 567 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id());
564 568
565 gfx::Rect work_area = 569 gfx::Rect work_area = display::Screen::GetScreen()
566 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); 570 ->GetDisplayNearestWindow(w1.get())
571 .work_area();
567 // Test that the top and bottom windows are clamped in work area and 572 // Test that the top and bottom windows are clamped in work area and
568 // that the overlaps between the windows differ at most by a pixel. 573 // that the overlaps between the windows differ at most by a pixel.
569 int gap1 = w1->GetBoundsInScreen().y() - work_area.y(); 574 int gap1 = w1->GetBoundsInScreen().y() - work_area.y();
570 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); 575 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom();
571 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); 576 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom();
572 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); 577 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom();
573 EXPECT_EQ(0, gap1); 578 EXPECT_EQ(0, gap1);
574 EXPECT_NEAR(gap2, min_dock_gap(), 1); 579 EXPECT_NEAR(gap2, min_dock_gap(), 1);
575 EXPECT_NEAR(gap3, min_dock_gap(), 1); 580 EXPECT_NEAR(gap3, min_dock_gap(), 1);
576 EXPECT_EQ(0, gap4); 581 EXPECT_EQ(0, gap4);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 756
752 // The two windows should be attached and snapped to the right edge. 757 // The two windows should be attached and snapped to the right edge.
753 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), 758 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
754 w1->GetBoundsInScreen().right()); 759 w1->GetBoundsInScreen().right());
755 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 760 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
756 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), 761 EXPECT_EQ(w2->GetRootWindow()->bounds().right(),
757 w2->GetBoundsInScreen().right()); 762 w2->GetBoundsInScreen().right());
758 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); 763 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
759 764
760 // The two windows should be same size vertically and almost 1/2 of work area. 765 // The two windows should be same size vertically and almost 1/2 of work area.
761 gfx::Rect work_area = 766 gfx::Rect work_area = display::Screen::GetScreen()
762 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); 767 ->GetDisplayNearestWindow(w1.get())
768 .work_area();
763 EXPECT_NEAR(w1->GetBoundsInScreen().height(), 769 EXPECT_NEAR(w1->GetBoundsInScreen().height(),
764 w2->GetBoundsInScreen().height(), 770 w2->GetBoundsInScreen().height(),
765 1); 771 1);
766 EXPECT_NEAR(work_area.height() / 2, w1->GetBoundsInScreen().height(), 772 EXPECT_NEAR(work_area.height() / 2, w1->GetBoundsInScreen().height(),
767 min_dock_gap() * 2); 773 min_dock_gap() * 2);
768 774
769 // Create and dock the third window. 775 // Create and dock the third window.
770 std::unique_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); 776 std::unique_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204)));
771 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); 777 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300);
772 778
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), 819 EXPECT_EQ(w2->GetRootWindow()->bounds().right(),
814 w2->GetBoundsInScreen().right()); 820 w2->GetBoundsInScreen().right());
815 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); 821 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
816 822
817 // The two windows should have their heights restricted. 823 // The two windows should have their heights restricted.
818 EXPECT_EQ(300, w1->GetBoundsInScreen().height()); 824 EXPECT_EQ(300, w1->GetBoundsInScreen().height());
819 EXPECT_EQ(100, w2->GetBoundsInScreen().height()); 825 EXPECT_EQ(100, w2->GetBoundsInScreen().height());
820 826
821 // w1 should be more than half of the work area height (even with a margin). 827 // w1 should be more than half of the work area height (even with a margin).
822 // w2 should be less than half of the work area height (even with a margin). 828 // w2 should be less than half of the work area height (even with a margin).
823 gfx::Rect work_area = 829 gfx::Rect work_area = display::Screen::GetScreen()
824 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); 830 ->GetDisplayNearestWindow(w1.get())
831 .work_area();
825 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10); 832 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10);
826 EXPECT_LT(w2->GetBoundsInScreen().height(), work_area.height() / 2 - 10); 833 EXPECT_LT(w2->GetBoundsInScreen().height(), work_area.height() / 2 - 10);
827 } 834 }
828 835
829 // Tests that a docked window is moved to primary display when secondary display 836 // Tests that a docked window is moved to primary display when secondary display
830 // is disconnected and that it stays docked and properly positioned. 837 // is disconnected and that it stays docked and properly positioned.
831 TEST_P(DockedWindowLayoutManagerTest, DisplayDisconnectionMovesDocked) { 838 TEST_P(DockedWindowLayoutManagerTest, DisplayDisconnectionMovesDocked) {
832 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) 839 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize())
833 return; 840 return;
834 841
835 // Create a dual screen layout. 842 // Create a dual screen layout.
836 UpdateDisplay("600x700,800x600"); 843 UpdateDisplay("600x700,800x600");
837 844
838 gfx::Rect bounds(600, 0, 201, 201); 845 gfx::Rect bounds(600, 0, 201, 201);
839 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); 846 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds));
840 // Drag pointer to the right edge of the second screen. 847 // Drag pointer to the right edge of the second screen.
841 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 848 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
842 849
843 // Simulate disconnection of the secondary display. 850 // Simulate disconnection of the secondary display.
844 UpdateDisplay("600x700"); 851 UpdateDisplay("600x700");
845 852
846 // The window should be still docked at the right edge. 853 // The window should be still docked at the right edge.
847 // Its height should grow to match the new work area. 854 // Its height should grow to match the new work area.
848 EXPECT_EQ(window->GetRootWindow()->bounds().right(), 855 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
849 window->GetBoundsInScreen().right()); 856 window->GetBoundsInScreen().right());
850 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); 857 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
851 EXPECT_EQ(ideal_width(), window->bounds().width()); 858 EXPECT_EQ(ideal_width(), window->bounds().width());
852 gfx::Rect work_area = gfx::Screen::GetScreen() 859 gfx::Rect work_area = display::Screen::GetScreen()
853 ->GetDisplayNearestWindow(window.get()) 860 ->GetDisplayNearestWindow(window.get())
854 .work_area(); 861 .work_area();
855 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); 862 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height());
856 } 863 }
857 864
858 // Tests run twice - on both panels and normal windows 865 // Tests run twice - on both panels and normal windows
859 INSTANTIATE_TEST_CASE_P(NormalOrPanel, 866 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
860 DockedWindowLayoutManagerTest, 867 DockedWindowLayoutManagerTest,
861 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, 868 testing::Values(ui::wm::WINDOW_TYPE_NORMAL,
862 ui::wm::WINDOW_TYPE_PANEL)); 869 ui::wm::WINDOW_TYPE_PANEL));
863 870
864 } // namespace ash 871 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/common/wm_window.h ('k') | ash/wm/dock/docked_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698