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

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

Issue 1998933002: Update shelf spacing in Chrome OS according to the MD specs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 6 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.cc ('k') | ash/shelf/shelf_view.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) 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/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
11 #include "ash/common/shelf/shelf_constants.h"
11 #include "ash/common/shell_window_ids.h" 12 #include "ash/common/shell_window_ids.h"
12 #include "ash/common/system/tray/system_tray_item.h" 13 #include "ash/common/system/tray/system_tray_item.h"
13 #include "ash/common/wm/window_state.h" 14 #include "ash/common/wm/window_state.h"
14 #include "ash/display/display_manager.h" 15 #include "ash/display/display_manager.h"
15 #include "ash/display/window_tree_host_manager.h" 16 #include "ash/display/window_tree_host_manager.h"
16 #include "ash/focus_cycler.h" 17 #include "ash/focus_cycler.h"
17 #include "ash/root_window_controller.h" 18 #include "ash/root_window_controller.h"
18 #include "ash/shelf/shelf.h" 19 #include "ash/shelf/shelf.h"
19 #include "ash/shelf/shelf_layout_manager_observer.h" 20 #include "ash/shelf/shelf_layout_manager_observer.h"
20 #include "ash/shelf/shelf_locking_manager.h" 21 #include "ash/shelf/shelf_locking_manager.h"
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 // Widget is now owned by the parent window. 849 // Widget is now owned by the parent window.
849 widget->Init(params); 850 widget->Init(params);
850 widget->Maximize(); 851 widget->Maximize();
851 widget->Show(); 852 widget->Show();
852 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 853 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
853 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 854 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
854 855
855 // LayoutShelf() forces the animation to completion, at which point the 856 // LayoutShelf() forces the animation to completion, at which point the
856 // shelf should go off the screen. 857 // shelf should go off the screen.
857 layout_manager->LayoutShelf(); 858 layout_manager->LayoutShelf();
858 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 859 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize,
859 GetShelfWidget()->GetWindowBoundsInScreen().y()); 860 GetShelfWidget()->GetWindowBoundsInScreen().y());
860 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 861 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize,
861 display::Screen::GetScreen() 862 display::Screen::GetScreen()
862 ->GetDisplayNearestWindow(root) 863 ->GetDisplayNearestWindow(root)
863 .work_area() 864 .work_area()
864 .bottom()); 865 .bottom());
865 866
866 // Move the mouse to the bottom of the screen. 867 // Move the mouse to the bottom of the screen.
867 generator.MoveMouseTo(0, root->bounds().bottom() - 1); 868 generator.MoveMouseTo(0, root->bounds().bottom() - 1);
868 869
869 // Shelf should be shown again (but it shouldn't have changed the work area). 870 // Shelf should be shown again (but it shouldn't have changed the work area).
870 SetState(layout_manager, SHELF_AUTO_HIDE); 871 SetState(layout_manager, SHELF_AUTO_HIDE);
871 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 872 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
872 layout_manager->LayoutShelf(); 873 layout_manager->LayoutShelf();
873 EXPECT_EQ(root->bounds().bottom() - layout_manager->GetIdealBounds().height(), 874 EXPECT_EQ(root->bounds().bottom() - layout_manager->GetIdealBounds().height(),
874 GetShelfWidget()->GetWindowBoundsInScreen().y()); 875 GetShelfWidget()->GetWindowBoundsInScreen().y());
875 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 876 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize,
876 display::Screen::GetScreen() 877 display::Screen::GetScreen()
877 ->GetDisplayNearestWindow(root) 878 ->GetDisplayNearestWindow(root)
878 .work_area() 879 .work_area()
879 .bottom()); 880 .bottom());
880 881
881 // Move mouse back up. 882 // Move mouse back up.
882 generator.MoveMouseTo(0, 0); 883 generator.MoveMouseTo(0, 0);
883 SetState(layout_manager, SHELF_AUTO_HIDE); 884 SetState(layout_manager, SHELF_AUTO_HIDE);
884 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 885 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
885 layout_manager->LayoutShelf(); 886 layout_manager->LayoutShelf();
886 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 887 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize,
887 GetShelfWidget()->GetWindowBoundsInScreen().y()); 888 GetShelfWidget()->GetWindowBoundsInScreen().y());
888 889
889 // Drag mouse to bottom of screen. 890 // Drag mouse to bottom of screen.
890 generator.PressLeftButton(); 891 generator.PressLeftButton();
891 generator.MoveMouseTo(0, root->bounds().bottom() - 1); 892 generator.MoveMouseTo(0, root->bounds().bottom() - 1);
892 UpdateAutoHideStateNow(); 893 UpdateAutoHideStateNow();
893 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 894 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
894 895
895 generator.ReleaseLeftButton(); 896 generator.ReleaseLeftButton();
896 generator.MoveMouseTo(1, root->bounds().bottom() - 1); 897 generator.MoveMouseTo(1, root->bounds().bottom() - 1);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 widget->Init(params); 1019 widget->Init(params);
1019 widget->Maximize(); 1020 widget->Maximize();
1020 widget->Show(); 1021 widget->Show();
1021 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1022 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1022 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1023 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1023 1024
1024 aura::Window* root = Shell::GetPrimaryRootWindow(); 1025 aura::Window* root = Shell::GetPrimaryRootWindow();
1025 // LayoutShelf() forces the animation to completion, at which point the 1026 // LayoutShelf() forces the animation to completion, at which point the
1026 // shelf should go off the screen. 1027 // shelf should go off the screen.
1027 layout_manager->LayoutShelf(); 1028 layout_manager->LayoutShelf();
1028 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 1029 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize,
1029 GetShelfWidget()->GetWindowBoundsInScreen().y()); 1030 GetShelfWidget()->GetWindowBoundsInScreen().y());
1030 1031
1031 aura::Window* lock_container = Shell::GetContainer( 1032 aura::Window* lock_container = Shell::GetContainer(
1032 Shell::GetPrimaryRootWindow(), kShellWindowId_LockScreenContainer); 1033 Shell::GetPrimaryRootWindow(), kShellWindowId_LockScreenContainer);
1033 1034
1034 views::Widget* lock_widget = new views::Widget; 1035 views::Widget* lock_widget = new views::Widget;
1035 views::Widget::InitParams lock_params( 1036 views::Widget::InitParams lock_params(
1036 views::Widget::InitParams::TYPE_WINDOW); 1037 views::Widget::InitParams::TYPE_WINDOW);
1037 lock_params.bounds = gfx::Rect(0, 0, 200, 200); 1038 lock_params.bounds = gfx::Rect(0, 0, 200, 200);
1038 params.context = CurrentContext(); 1039 params.context = CurrentContext();
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 EXPECT_EQ(layout_manager->GetIdealBounds().width(), 1696 EXPECT_EQ(layout_manager->GetIdealBounds().width(),
1696 display.GetWorkAreaInsets().left()); 1697 display.GetWorkAreaInsets().left());
1697 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); 1698 EXPECT_EQ(0, display.GetWorkAreaInsets().top());
1698 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); 1699 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
1699 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); 1700 EXPECT_EQ(0, display.GetWorkAreaInsets().right());
1700 EXPECT_EQ(display.bounds().x(), shelf_bounds.x()); 1701 EXPECT_EQ(display.bounds().x(), shelf_bounds.x());
1701 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); 1702 EXPECT_EQ(display.bounds().y(), shelf_bounds.y());
1702 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); 1703 EXPECT_EQ(display.bounds().height(), shelf_bounds.height());
1703 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1704 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1704 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); 1705 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
1705 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, 1706 EXPECT_EQ(kShelfAutoHideSize, display.GetWorkAreaInsets().left());
1706 display.GetWorkAreaInsets().left()); 1707 EXPECT_EQ(kShelfAutoHideSize, display.work_area().x());
1707 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, display.work_area().x());
1708 1708
1709 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1709 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1710 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 1710 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
1711 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); 1711 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
1712 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); 1712 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
1713 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); 1713 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
1714 ASSERT_NE(-1, display.id()); 1714 ASSERT_NE(-1, display.id());
1715 EXPECT_EQ(layout_manager->GetIdealBounds().width(), 1715 EXPECT_EQ(layout_manager->GetIdealBounds().width(),
1716 display.GetWorkAreaInsets().right()); 1716 display.GetWorkAreaInsets().right());
1717 EXPECT_GE(shelf_bounds.width(), 1717 EXPECT_GE(shelf_bounds.width(),
1718 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); 1718 GetShelfWidget()->GetContentsView()->GetPreferredSize().width());
1719 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment()); 1719 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment());
1720 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); 1720 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen());
1721 EXPECT_GE(status_bounds.width(), 1721 EXPECT_GE(status_bounds.width(),
1722 status_area_widget->GetContentsView()->GetPreferredSize().width()); 1722 status_area_widget->GetContentsView()->GetPreferredSize().width());
1723 EXPECT_EQ(layout_manager->GetIdealBounds().width(), 1723 EXPECT_EQ(layout_manager->GetIdealBounds().width(),
1724 display.GetWorkAreaInsets().right()); 1724 display.GetWorkAreaInsets().right());
1725 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); 1725 EXPECT_EQ(0, display.GetWorkAreaInsets().top());
1726 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); 1726 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
1727 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); 1727 EXPECT_EQ(0, display.GetWorkAreaInsets().left());
1728 EXPECT_EQ(display.work_area().right(), shelf_bounds.x()); 1728 EXPECT_EQ(display.work_area().right(), shelf_bounds.x());
1729 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); 1729 EXPECT_EQ(display.bounds().y(), shelf_bounds.y());
1730 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); 1730 EXPECT_EQ(display.bounds().height(), shelf_bounds.height());
1731 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1731 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1732 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); 1732 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
1733 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, 1733 EXPECT_EQ(kShelfAutoHideSize, display.GetWorkAreaInsets().right());
1734 display.GetWorkAreaInsets().right()); 1734 EXPECT_EQ(kShelfAutoHideSize,
1735 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, 1735 display.bounds().right() - display.work_area().right());
1736 display.bounds().right() - display.work_area().right());
1737 } 1736 }
1738 1737
1739 TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) { 1738 TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) {
1740 Shelf* shelf = GetShelf(); 1739 Shelf* shelf = GetShelf();
1741 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1740 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1742 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1741 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1743 views::Widget* widget = new views::Widget; 1742 views::Widget* widget = new views::Widget;
1744 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 1743 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
1745 params.bounds = gfx::Rect(0, 0, 200, 200); 1744 params.bounds = gfx::Rect(0, 0, 200, 200);
1746 params.context = CurrentContext(); 1745 params.context = CurrentContext();
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
2292 ->shelf_widget() 2291 ->shelf_widget()
2293 ->status_area_widget(); 2292 ->status_area_widget();
2294 EXPECT_TRUE(status_area_widget->IsVisible()); 2293 EXPECT_TRUE(status_area_widget->IsVisible());
2295 // Shelf should be in the first display's area. 2294 // Shelf should be in the first display's area.
2296 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); 2295 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen());
2297 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));
2298 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); 2297 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right());
2299 } 2298 }
2300 2299
2301 } // namespace ash 2300 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.cc ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698