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

Side by Side Diff: ash/shelf/shelf_layout_manager_unittest.cc

Issue 1914093002: Refactors DockedWindowLayoutManager in terms of ash/wm/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nuke_aura_window
Patch Set: comment Created 4 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
« no previous file with comments | « ash/shelf/shelf_layout_manager_observer.h ('k') | ash/shelf/shelf_locking_manager.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h" 8 #include "ash/accelerators/accelerator_table.h"
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 if (type == ui::ET_GESTURE_SCROLL_END) 155 if (type == ui::ET_GESTURE_SCROLL_END)
156 return; 156 return;
157 157
158 if (type == ui::ET_GESTURE_SCROLL_UPDATE) 158 if (type == ui::ET_GESTURE_SCROLL_UPDATE)
159 scroll_.Add(delta); 159 scroll_.Add(delta);
160 160
161 gfx::Rect shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); 161 gfx::Rect shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
162 if (GetShelfLayoutManager()->IsHorizontalAlignment()) { 162 if (GetShelfLayoutManager()->IsHorizontalAlignment()) {
163 EXPECT_EQ(not_visible_bounds_.bottom(), shelf_bounds.bottom()); 163 EXPECT_EQ(not_visible_bounds_.bottom(), shelf_bounds.bottom());
164 EXPECT_EQ(visible_bounds_.bottom(), shelf_bounds.bottom()); 164 EXPECT_EQ(visible_bounds_.bottom(), shelf_bounds.bottom());
165 } else if (SHELF_ALIGNMENT_RIGHT == 165 } else if (wm::SHELF_ALIGNMENT_RIGHT ==
166 GetShelfLayoutManager()->GetAlignment()){ 166 GetShelfLayoutManager()->GetAlignment()) {
167 EXPECT_EQ(not_visible_bounds_.right(), shelf_bounds.right()); 167 EXPECT_EQ(not_visible_bounds_.right(), shelf_bounds.right());
168 EXPECT_EQ(visible_bounds_.right(), shelf_bounds.right()); 168 EXPECT_EQ(visible_bounds_.right(), shelf_bounds.right());
169 } else if (SHELF_ALIGNMENT_LEFT == 169 } else if (wm::SHELF_ALIGNMENT_LEFT ==
170 GetShelfLayoutManager()->GetAlignment()) { 170 GetShelfLayoutManager()->GetAlignment()) {
171 EXPECT_EQ(not_visible_bounds_.x(), shelf_bounds.x()); 171 EXPECT_EQ(not_visible_bounds_.x(), shelf_bounds.x());
172 EXPECT_EQ(visible_bounds_.x(), shelf_bounds.x()); 172 EXPECT_EQ(visible_bounds_.x(), shelf_bounds.x());
173 } 173 }
174 174
175 // if the shelf is being dimmed test dimmer bounds as well. 175 // if the shelf is being dimmed test dimmer bounds as well.
176 if (GetShelfWidget()->GetDimsShelf()) 176 if (GetShelfWidget()->GetDimsShelf())
177 EXPECT_EQ(GetShelfWidget()->GetWindowBoundsInScreen(), 177 EXPECT_EQ(GetShelfWidget()->GetWindowBoundsInScreen(),
178 GetShelfWidget()->GetDimmerBoundsForTest()); 178 GetShelfWidget()->GetDimmerBoundsForTest());
179 179
180 // The shelf should never be smaller than the hidden state. 180 // The shelf should never be smaller than the hidden state.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 end, 474 end,
475 start, 475 start,
476 kTimeDelta, 476 kTimeDelta,
477 kNumScrollSteps, 477 kNumScrollSteps,
478 base::Bind(&ShelfDragCallback::ProcessScroll, 478 base::Bind(&ShelfDragCallback::ProcessScroll,
479 base::Unretained(&handler))); 479 base::Unretained(&handler)));
480 480
481 // Swipe down very little. It shouldn't change any state. 481 // Swipe down very little. It shouldn't change any state.
482 if (GetShelfLayoutManager()->IsHorizontalAlignment()) 482 if (GetShelfLayoutManager()->IsHorizontalAlignment())
483 end.set_y(start.y() + shelf_shown.height() * 3 / 10); 483 end.set_y(start.y() + shelf_shown.height() * 3 / 10);
484 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) 484 else if (wm::SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment())
485 end.set_x(start.x() - shelf_shown.width() * 3 / 10); 485 end.set_x(start.x() - shelf_shown.width() * 3 / 10);
486 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) 486 else if (wm::SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment())
487 end.set_x(start.x() + shelf_shown.width() * 3 / 10); 487 end.set_x(start.x() + shelf_shown.width() * 3 / 10);
488 generator.GestureScrollSequence(start, end, kTimeDelta, 5); 488 generator.GestureScrollSequence(start, end, kTimeDelta, 5);
489 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 489 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
490 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); 490 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
491 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); 491 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString());
492 EXPECT_EQ(shelf_shown.ToString(), 492 EXPECT_EQ(shelf_shown.ToString(),
493 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); 493 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
494 494
495 // Swipe down again to hide. 495 // Swipe down again to hide.
496 end = start + delta; 496 end = start + delta;
497 generator.GestureScrollSequenceWithCallback( 497 generator.GestureScrollSequenceWithCallback(
498 start, 498 start,
499 end, 499 end,
500 kTimeDelta, 500 kTimeDelta,
501 kNumScrollSteps, 501 kNumScrollSteps,
502 base::Bind(&ShelfDragCallback::ProcessScroll, 502 base::Bind(&ShelfDragCallback::ProcessScroll,
503 base::Unretained(&handler))); 503 base::Unretained(&handler)));
504 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 504 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
505 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 505 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
506 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); 506 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
507 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); 507 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect());
508 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); 508 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString());
509 EXPECT_EQ(shelf_hidden.ToString(), 509 EXPECT_EQ(shelf_hidden.ToString(),
510 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); 510 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
511 511
512 // Swipe up in extended hit region to show it. 512 // Swipe up in extended hit region to show it.
513 gfx::Point extended_start = start; 513 gfx::Point extended_start = start;
514 if (GetShelfLayoutManager()->IsHorizontalAlignment()) 514 if (GetShelfLayoutManager()->IsHorizontalAlignment())
515 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() -1); 515 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() -1);
516 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) 516 else if (wm::SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment())
517 extended_start.set_x( 517 extended_start.set_x(
518 GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); 518 GetShelfWidget()->GetWindowBoundsInScreen().right() + 1);
519 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) 519 else if (wm::SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment())
520 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); 520 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1);
521 end = extended_start - delta; 521 end = extended_start - delta;
522 generator.GestureScrollSequenceWithCallback( 522 generator.GestureScrollSequenceWithCallback(
523 extended_start, 523 extended_start,
524 end, 524 end,
525 kTimeDelta, 525 kTimeDelta,
526 kNumScrollSteps, 526 kNumScrollSteps,
527 base::Bind(&ShelfDragCallback::ProcessScroll, 527 base::Bind(&ShelfDragCallback::ProcessScroll,
528 base::Unretained(&handler))); 528 base::Unretained(&handler)));
529 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 529 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 563 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
564 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); 564 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
565 EXPECT_EQ(shelf_hidden.ToString(), 565 EXPECT_EQ(shelf_hidden.ToString(),
566 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); 566 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
567 567
568 // Swipe up from below the shelf where a bezel would be, this should show the 568 // Swipe up from below the shelf where a bezel would be, this should show the
569 // shelf. 569 // shelf.
570 gfx::Point below_start = start; 570 gfx::Point below_start = start;
571 if (GetShelfLayoutManager()->IsHorizontalAlignment()) 571 if (GetShelfLayoutManager()->IsHorizontalAlignment())
572 below_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().bottom() + 1); 572 below_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().bottom() + 1);
573 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) 573 else if (wm::SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment())
574 below_start.set_x( 574 below_start.set_x(
575 GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); 575 GetShelfWidget()->GetWindowBoundsInScreen().x() - 1);
576 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) 576 else if (wm::SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment())
577 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); 577 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1);
578 end = below_start - delta; 578 end = below_start - delta;
579 generator.GestureScrollSequence( 579 generator.GestureScrollSequence(
580 below_start, end, kTimeDelta, kNumScrollSteps); 580 below_start, end, kTimeDelta, kNumScrollSteps);
581 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 581 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
582 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); 582 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
583 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); 583 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString());
584 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), 584 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(),
585 GetShelfWidget()->GetWindowBoundsInScreen()); 585 GetShelfWidget()->GetWindowBoundsInScreen());
586 EXPECT_EQ(shelf_shown.ToString(), 586 EXPECT_EQ(shelf_shown.ToString(),
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 // boundary between the primary and the secondary display. 893 // boundary between the primary and the secondary display.
894 TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) { 894 TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) {
895 if (!SupportsMultipleDisplays()) 895 if (!SupportsMultipleDisplays())
896 return; 896 return;
897 897
898 UpdateDisplay("800x600,800x600"); 898 UpdateDisplay("800x600,800x600");
899 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 899 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
900 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 0)); 900 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 0));
901 // Put the primary monitor's shelf on the display boundary. 901 // Put the primary monitor's shelf on the display boundary.
902 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 902 ShelfLayoutManager* shelf = GetShelfLayoutManager();
903 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 903 shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
904 904
905 // Create a window because the shelf is always shown when no windows are 905 // Create a window because the shelf is always shown when no windows are
906 // visible. 906 // visible.
907 CreateTestWidget(); 907 CreateTestWidget();
908 908
909 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 909 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
910 ASSERT_EQ(root_windows[0], 910 ASSERT_EQ(root_windows[0],
911 GetShelfWidget()->GetNativeWindow()->GetRootWindow()); 911 GetShelfWidget()->GetNativeWindow()->GetRootWindow());
912 912
913 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 913 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 } 1649 }
1650 1650
1651 1651
1652 #if defined(OS_WIN) 1652 #if defined(OS_WIN)
1653 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 1653 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962
1654 #define MAYBE_SetAlignment DISABLED_SetAlignment 1654 #define MAYBE_SetAlignment DISABLED_SetAlignment
1655 #else 1655 #else
1656 #define MAYBE_SetAlignment SetAlignment 1656 #define MAYBE_SetAlignment SetAlignment
1657 #endif 1657 #endif
1658 1658
1659 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). 1659 // Tests wm::SHELF_ALIGNMENT_(LEFT, RIGHT).
1660 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { 1660 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) {
1661 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1661 ShelfLayoutManager* shelf = GetShelfLayoutManager();
1662 // Force an initial layout. 1662 // Force an initial layout.
1663 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1663 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1664 shelf->LayoutShelf(); 1664 shelf->LayoutShelf();
1665 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1665 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1666 1666
1667 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 1667 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
1668 gfx::Rect shelf_bounds( 1668 gfx::Rect shelf_bounds(
1669 GetShelfWidget()->GetWindowBoundsInScreen()); 1669 GetShelfWidget()->GetWindowBoundsInScreen());
1670 const gfx::Screen* screen = gfx::Screen::GetScreen(); 1670 const gfx::Screen* screen = gfx::Screen::GetScreen();
1671 gfx::Display display = 1671 gfx::Display display =
1672 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); 1672 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
1673 ASSERT_NE(-1, display.id()); 1673 ASSERT_NE(-1, display.id());
1674 EXPECT_EQ(shelf->GetIdealBounds().width(), 1674 EXPECT_EQ(shelf->GetIdealBounds().width(),
1675 display.GetWorkAreaInsets().left()); 1675 display.GetWorkAreaInsets().left());
1676 EXPECT_GE( 1676 EXPECT_GE(
1677 shelf_bounds.width(), 1677 shelf_bounds.width(),
1678 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); 1678 GetShelfWidget()->GetContentsView()->GetPreferredSize().width());
1679 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); 1679 EXPECT_EQ(wm::SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment());
1680 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); 1680 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget();
1681 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); 1681 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen());
1682 EXPECT_GE(status_bounds.width(), 1682 EXPECT_GE(status_bounds.width(),
1683 status_area_widget->GetContentsView()->GetPreferredSize().width()); 1683 status_area_widget->GetContentsView()->GetPreferredSize().width());
1684 EXPECT_EQ(shelf->GetIdealBounds().width(), 1684 EXPECT_EQ(shelf->GetIdealBounds().width(),
1685 display.GetWorkAreaInsets().left()); 1685 display.GetWorkAreaInsets().left());
1686 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); 1686 EXPECT_EQ(0, display.GetWorkAreaInsets().top());
1687 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); 1687 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
1688 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); 1688 EXPECT_EQ(0, display.GetWorkAreaInsets().right());
1689 EXPECT_EQ(display.bounds().x(), shelf_bounds.x()); 1689 EXPECT_EQ(display.bounds().x(), shelf_bounds.x());
1690 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); 1690 EXPECT_EQ(display.bounds().y(), shelf_bounds.y());
1691 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); 1691 EXPECT_EQ(display.bounds().height(), shelf_bounds.height());
1692 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1692 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1693 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); 1693 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
1694 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, 1694 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize,
1695 display.GetWorkAreaInsets().left()); 1695 display.GetWorkAreaInsets().left());
1696 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, display.work_area().x()); 1696 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, display.work_area().x());
1697 1697
1698 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1698 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1699 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 1699 shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
1700 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); 1700 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
1701 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); 1701 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
1702 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); 1702 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
1703 ASSERT_NE(-1, display.id()); 1703 ASSERT_NE(-1, display.id());
1704 EXPECT_EQ(shelf->GetIdealBounds().width(), 1704 EXPECT_EQ(shelf->GetIdealBounds().width(),
1705 display.GetWorkAreaInsets().right()); 1705 display.GetWorkAreaInsets().right());
1706 EXPECT_GE(shelf_bounds.width(), 1706 EXPECT_GE(shelf_bounds.width(),
1707 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); 1707 GetShelfWidget()->GetContentsView()->GetPreferredSize().width());
1708 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment()); 1708 EXPECT_EQ(wm::SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment());
1709 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); 1709 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen());
1710 EXPECT_GE(status_bounds.width(), 1710 EXPECT_GE(status_bounds.width(),
1711 status_area_widget->GetContentsView()->GetPreferredSize().width()); 1711 status_area_widget->GetContentsView()->GetPreferredSize().width());
1712 EXPECT_EQ(shelf->GetIdealBounds().width(), 1712 EXPECT_EQ(shelf->GetIdealBounds().width(),
1713 display.GetWorkAreaInsets().right()); 1713 display.GetWorkAreaInsets().right());
1714 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); 1714 EXPECT_EQ(0, display.GetWorkAreaInsets().top());
1715 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); 1715 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
1716 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); 1716 EXPECT_EQ(0, display.GetWorkAreaInsets().left());
1717 EXPECT_EQ(display.work_area().right(), shelf_bounds.x()); 1717 EXPECT_EQ(display.work_area().right(), shelf_bounds.x());
1718 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); 1718 EXPECT_EQ(display.bounds().y(), shelf_bounds.y());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 ui::GestureConfiguration::GetInstance() 1853 ui::GestureConfiguration::GetInstance()
1854 ->set_max_touch_move_in_pixels_for_click(0); 1854 ->set_max_touch_move_in_pixels_for_click(0);
1855 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1855 ShelfLayoutManager* shelf = GetShelfLayoutManager();
1856 { 1856 {
1857 SCOPED_TRACE("BOTTOM"); 1857 SCOPED_TRACE("BOTTOM");
1858 RunGestureDragTests(gfx::Vector2d(0, 120)); 1858 RunGestureDragTests(gfx::Vector2d(0, 120));
1859 } 1859 }
1860 1860
1861 { 1861 {
1862 SCOPED_TRACE("LEFT"); 1862 SCOPED_TRACE("LEFT");
1863 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 1863 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
1864 RunGestureDragTests(gfx::Vector2d(-120, 0)); 1864 RunGestureDragTests(gfx::Vector2d(-120, 0));
1865 } 1865 }
1866 1866
1867 { 1867 {
1868 SCOPED_TRACE("RIGHT"); 1868 SCOPED_TRACE("RIGHT");
1869 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 1869 shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
1870 RunGestureDragTests(gfx::Vector2d(120, 0)); 1870 RunGestureDragTests(gfx::Vector2d(120, 0));
1871 } 1871 }
1872 } 1872 }
1873 1873
1874 TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) { 1874 TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) {
1875 if (!SupportsMultipleDisplays()) 1875 if (!SupportsMultipleDisplays())
1876 return; 1876 return;
1877 1877
1878 UpdateDisplay("800x600,800x600"); 1878 UpdateDisplay("800x600,800x600");
1879 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1879 ShelfLayoutManager* shelf = GetShelfLayoutManager();
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 EXPECT_TRUE(shelf->IsVisible()); 2135 EXPECT_TRUE(shelf->IsVisible());
2136 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); 2136 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown());
2137 } else { 2137 } else {
2138 EXPECT_FALSE(shelf->IsVisible()); 2138 EXPECT_FALSE(shelf->IsVisible());
2139 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 2139 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
2140 } 2140 }
2141 } 2141 }
2142 } 2142 }
2143 2143
2144 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColor) { 2144 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColor) {
2145 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); 2145 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT,
2146 GetShelfWidget()->GetBackgroundType());
2146 2147
2147 std::unique_ptr<aura::Window> w1(CreateTestWindow()); 2148 std::unique_ptr<aura::Window> w1(CreateTestWindow());
2148 w1->Show(); 2149 w1->Show();
2149 wm::ActivateWindow(w1.get()); 2150 wm::ActivateWindow(w1.get());
2150 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); 2151 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT,
2152 GetShelfWidget()->GetBackgroundType());
2151 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 2153 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
2152 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType()); 2154 EXPECT_EQ(wm::SHELF_BACKGROUND_MAXIMIZED,
2155 GetShelfWidget()->GetBackgroundType());
2153 2156
2154 std::unique_ptr<aura::Window> w2(CreateTestWindow()); 2157 std::unique_ptr<aura::Window> w2(CreateTestWindow());
2155 w2->Show(); 2158 w2->Show();
2156 wm::ActivateWindow(w2.get()); 2159 wm::ActivateWindow(w2.get());
2157 // Overlaps with shelf. 2160 // Overlaps with shelf.
2158 w2->SetBounds(GetShelfLayoutManager()->GetIdealBounds()); 2161 w2->SetBounds(GetShelfLayoutManager()->GetIdealBounds());
2159 2162
2160 // Still background is 'maximized'. 2163 // Still background is 'maximized'.
2161 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType()); 2164 EXPECT_EQ(wm::SHELF_BACKGROUND_MAXIMIZED,
2165 GetShelfWidget()->GetBackgroundType());
2162 2166
2163 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 2167 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
2164 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); 2168 EXPECT_EQ(wm::SHELF_BACKGROUND_OVERLAP,
2169 GetShelfWidget()->GetBackgroundType());
2165 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 2170 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
2166 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); 2171 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT,
2172 GetShelfWidget()->GetBackgroundType());
2167 2173
2168 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 2174 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
2169 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType()); 2175 EXPECT_EQ(wm::SHELF_BACKGROUND_MAXIMIZED,
2176 GetShelfWidget()->GetBackgroundType());
2170 w1.reset(); 2177 w1.reset();
2171 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); 2178 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT,
2179 GetShelfWidget()->GetBackgroundType());
2172 } 2180 }
2173 2181
2174 // Verify that the shelf doesn't have the opaque background if it's auto-hide 2182 // Verify that the shelf doesn't have the opaque background if it's auto-hide
2175 // status. 2183 // status.
2176 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) { 2184 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) {
2177 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget ()->GetBackgroundType()); 2185 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT,
2186 GetShelfWidget()->GetBackgroundType());
2178 2187
2179 GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 2188 GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
2180 std::unique_ptr<aura::Window> w1(CreateTestWindow()); 2189 std::unique_ptr<aura::Window> w1(CreateTestWindow());
2181 w1->Show(); 2190 w1->Show();
2182 wm::ActivateWindow(w1.get()); 2191 wm::ActivateWindow(w1.get());
2183 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); 2192 EXPECT_EQ(wm::SHELF_BACKGROUND_OVERLAP,
2193 GetShelfWidget()->GetBackgroundType());
2184 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 2194 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
2185 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); 2195 EXPECT_EQ(wm::SHELF_BACKGROUND_OVERLAP,
2196 GetShelfWidget()->GetBackgroundType());
2186 } 2197 }
2187 2198
2188 #if defined(OS_CHROMEOS) 2199 #if defined(OS_CHROMEOS)
2189 #define MAYBE_StatusAreaHitBoxCoversEdge StatusAreaHitBoxCoversEdge 2200 #define MAYBE_StatusAreaHitBoxCoversEdge StatusAreaHitBoxCoversEdge
2190 #else 2201 #else
2191 #define MAYBE_StatusAreaHitBoxCoversEdge DISABLED_StatusAreaHitBoxCoversEdge 2202 #define MAYBE_StatusAreaHitBoxCoversEdge DISABLED_StatusAreaHitBoxCoversEdge
2192 #endif 2203 #endif
2193 2204
2194 // Verify the hit bounds of the status area extend to the edge of the shelf. 2205 // Verify the hit bounds of the status area extend to the edge of the shelf.
2195 TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) { 2206 TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) {
2196 UpdateDisplay("400x400"); 2207 UpdateDisplay("400x400");
2197 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 2208 ShelfLayoutManager* shelf = GetShelfLayoutManager();
2198 StatusAreaWidget* status_area_widget = 2209 StatusAreaWidget* status_area_widget =
2199 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); 2210 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget();
2200 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 2211 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
2201 generator.MoveMouseTo(399,399); 2212 generator.MoveMouseTo(399,399);
2202 2213
2203 // Test bottom right pixel for bottom alignment. 2214 // Test bottom right pixel for bottom alignment.
2204 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 2215 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
2205 generator.ClickLeftButton(); 2216 generator.ClickLeftButton();
2206 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); 2217 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown());
2207 generator.ClickLeftButton(); 2218 generator.ClickLeftButton();
2208 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 2219 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
2209 2220
2210 // Test bottom right pixel for right alignment. 2221 // Test bottom right pixel for right alignment.
2211 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 2222 shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
2212 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 2223 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
2213 generator.ClickLeftButton(); 2224 generator.ClickLeftButton();
2214 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); 2225 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown());
2215 generator.ClickLeftButton(); 2226 generator.ClickLeftButton();
2216 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 2227 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
2217 2228
2218 // Test bottom left pixel for left alignment. 2229 // Test bottom left pixel for left alignment.
2219 generator.MoveMouseTo(0, 399); 2230 generator.MoveMouseTo(0, 399);
2220 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 2231 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
2221 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 2232 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
2222 generator.ClickLeftButton(); 2233 generator.ClickLeftButton();
2223 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); 2234 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown());
2224 generator.ClickLeftButton(); 2235 generator.ClickLeftButton();
2225 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 2236 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
2226 } 2237 }
2227 2238
2228 // Tests that when the auto-hide behaviour is changed during an animation the 2239 // Tests that when the auto-hide behaviour is changed during an animation the
2229 // target bounds are updated to reflect the new state. 2240 // target bounds are updated to reflect the new state.
2230 TEST_F(ShelfLayoutManagerTest, 2241 TEST_F(ShelfLayoutManagerTest,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 StatusAreaWidget* status_area_widget = 2291 StatusAreaWidget* status_area_widget =
2281 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); 2292 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget();
2282 EXPECT_TRUE(status_area_widget->IsVisible()); 2293 EXPECT_TRUE(status_area_widget->IsVisible());
2283 // Shelf should be in the first display's area. 2294 // Shelf should be in the first display's area.
2284 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); 2295 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen());
2285 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); 2296 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds));
2286 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); 2297 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right());
2287 } 2298 }
2288 2299
2289 } // namespace ash 2300 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager_observer.h ('k') | ash/shelf/shelf_locking_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698