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

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

Issue 1608053002: Remove now-unnecessary wrappers around gfx::Screen::GetScreen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-5
Patch Set: cros Created 4 years, 10 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_window_watcher.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/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 ShelfLayoutManager* manager = shelf->shelf_layout_manager(); 710 ShelfLayoutManager* manager = shelf->shelf_layout_manager();
711 // Force an initial layout. 711 // Force an initial layout.
712 manager->LayoutShelf(); 712 manager->LayoutShelf();
713 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); 713 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state());
714 714
715 gfx::Rect status_bounds( 715 gfx::Rect status_bounds(
716 shelf->status_area_widget()->GetWindowBoundsInScreen()); 716 shelf->status_area_widget()->GetWindowBoundsInScreen());
717 gfx::Rect shelf_bounds( 717 gfx::Rect shelf_bounds(
718 shelf->GetWindowBoundsInScreen()); 718 shelf->GetWindowBoundsInScreen());
719 int shelf_height = manager->GetIdealBounds().height(); 719 int shelf_height = manager->GetIdealBounds().height();
720 gfx::Screen* screen = Shell::GetScreen(); 720 gfx::Screen* screen = gfx::Screen::GetScreen();
721 gfx::Display display = screen->GetDisplayNearestWindow( 721 gfx::Display display = screen->GetDisplayNearestWindow(
722 Shell::GetPrimaryRootWindow()); 722 Shell::GetPrimaryRootWindow());
723 ASSERT_NE(-1, display.id()); 723 ASSERT_NE(-1, display.id());
724 // Bottom inset should be the max of widget heights. 724 // Bottom inset should be the max of widget heights.
725 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); 725 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom());
726 726
727 // Hide the shelf. 727 // Hide the shelf.
728 SetState(manager, SHELF_HIDDEN); 728 SetState(manager, SHELF_HIDDEN);
729 // Run the animation to completion. 729 // Run the animation to completion.
730 StepWidgetLayerAnimatorToEnd(shelf); 730 StepWidgetLayerAnimatorToEnd(shelf);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 807 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
808 ShelfWidget* shelf = GetShelfWidget(); 808 ShelfWidget* shelf = GetShelfWidget();
809 // Force an initial layout. 809 // Force an initial layout.
810 shelf->shelf_layout_manager()->LayoutShelf(); 810 shelf->shelf_layout_manager()->LayoutShelf();
811 EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state()); 811 EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state());
812 812
813 // Hide the shelf. 813 // Hide the shelf.
814 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN); 814 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN);
815 shelf->shelf_layout_manager()->LayoutShelf(); 815 shelf->shelf_layout_manager()->LayoutShelf();
816 EXPECT_EQ(SHELF_HIDDEN, shelf->shelf_layout_manager()->visibility_state()); 816 EXPECT_EQ(SHELF_HIDDEN, shelf->shelf_layout_manager()->visibility_state());
817 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( 817 gfx::Display display = gfx::Screen::GetScreen()->GetDisplayNearestWindow(
818 Shell::GetPrimaryRootWindow()); 818 Shell::GetPrimaryRootWindow());
819 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); 819 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
820 820
821 // Make sure the bounds of the two widgets changed. 821 // Make sure the bounds of the two widgets changed.
822 EXPECT_GE(shelf->GetNativeView()->bounds().y(), 822 EXPECT_GE(shelf->GetNativeView()->bounds().y(),
823 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); 823 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom());
824 EXPECT_GE(shelf->status_area_widget()->GetNativeView()->bounds().y(), 824 EXPECT_GE(shelf->status_area_widget()->GetNativeView()->bounds().y(),
825 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); 825 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom());
826 } 826 }
827 827
828 // Test that switching to a different visibility state does not restart the 828 // Test that switching to a different visibility state does not restart the
829 // shelf show / hide animation if it is already running. (crbug.com/250918) 829 // shelf show / hide animation if it is already running. (crbug.com/250918)
830 TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) { 830 TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) {
831 ShelfWidget* shelf = GetShelfWidget(); 831 ShelfWidget* shelf = GetShelfWidget();
832 SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE); 832 SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE);
833 gfx::Rect initial_shelf_bounds = shelf->GetWindowBoundsInScreen(); 833 gfx::Rect initial_shelf_bounds = shelf->GetWindowBoundsInScreen();
834 gfx::Rect initial_status_bounds = 834 gfx::Rect initial_status_bounds =
835 shelf->status_area_widget()->GetWindowBoundsInScreen(); 835 shelf->status_area_widget()->GetWindowBoundsInScreen();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 widget->Show(); 891 widget->Show();
892 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 892 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
893 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 893 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
894 894
895 // LayoutShelf() forces the animation to completion, at which point the 895 // LayoutShelf() forces the animation to completion, at which point the
896 // shelf should go off the screen. 896 // shelf should go off the screen.
897 shelf->LayoutShelf(); 897 shelf->LayoutShelf();
898 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 898 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
899 GetShelfWidget()->GetWindowBoundsInScreen().y()); 899 GetShelfWidget()->GetWindowBoundsInScreen().y());
900 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 900 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
901 Shell::GetScreen()->GetDisplayNearestWindow( 901 gfx::Screen::GetScreen()
902 root).work_area().bottom()); 902 ->GetDisplayNearestWindow(root)
903 .work_area()
904 .bottom());
903 905
904 // Move the mouse to the bottom of the screen. 906 // Move the mouse to the bottom of the screen.
905 generator.MoveMouseTo(0, root->bounds().bottom() - 1); 907 generator.MoveMouseTo(0, root->bounds().bottom() - 1);
906 908
907 // Shelf should be shown again (but it shouldn't have changed the work area). 909 // Shelf should be shown again (but it shouldn't have changed the work area).
908 SetState(shelf, SHELF_AUTO_HIDE); 910 SetState(shelf, SHELF_AUTO_HIDE);
909 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 911 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
910 shelf->LayoutShelf(); 912 shelf->LayoutShelf();
911 EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(), 913 EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(),
912 GetShelfWidget()->GetWindowBoundsInScreen().y()); 914 GetShelfWidget()->GetWindowBoundsInScreen().y());
913 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 915 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
914 Shell::GetScreen()->GetDisplayNearestWindow( 916 gfx::Screen::GetScreen()
915 root).work_area().bottom()); 917 ->GetDisplayNearestWindow(root)
918 .work_area()
919 .bottom());
916 920
917 // Move mouse back up. 921 // Move mouse back up.
918 generator.MoveMouseTo(0, 0); 922 generator.MoveMouseTo(0, 0);
919 SetState(shelf, SHELF_AUTO_HIDE); 923 SetState(shelf, SHELF_AUTO_HIDE);
920 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 924 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
921 shelf->LayoutShelf(); 925 shelf->LayoutShelf();
922 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 926 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
923 GetShelfWidget()->GetWindowBoundsInScreen().y()); 927 GetShelfWidget()->GetWindowBoundsInScreen().y());
924 928
925 // Drag mouse to bottom of screen. 929 // Drag mouse to bottom of screen.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 ui::test::EventGenerator& generator(GetEventGenerator()); 974 ui::test::EventGenerator& generator(GetEventGenerator());
971 generator.MoveMouseTo(right_edge - 50, y); 975 generator.MoveMouseTo(right_edge - 50, y);
972 UpdateAutoHideStateNow(); 976 UpdateAutoHideStateNow();
973 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 977 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
974 978
975 // Moving the mouse over the light bar (but not to the edge of the screen) 979 // Moving the mouse over the light bar (but not to the edge of the screen)
976 // should show the shelf. 980 // should show the shelf.
977 generator.MoveMouseTo(right_edge - 1, y); 981 generator.MoveMouseTo(right_edge - 1, y);
978 UpdateAutoHideStateNow(); 982 UpdateAutoHideStateNow();
979 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 983 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
980 EXPECT_EQ(right_edge - 1, Shell::GetScreen()->GetCursorScreenPoint().x()); 984 EXPECT_EQ(right_edge - 1,
985 gfx::Screen::GetScreen()->GetCursorScreenPoint().x());
981 986
982 // Moving the mouse off the light bar should hide the shelf. 987 // Moving the mouse off the light bar should hide the shelf.
983 generator.MoveMouseTo(right_edge - 50, y); 988 generator.MoveMouseTo(right_edge - 50, y);
984 UpdateAutoHideStateNow(); 989 UpdateAutoHideStateNow();
985 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 990 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
986 991
987 // Moving the mouse to the right edge of the screen crossing the light bar 992 // Moving the mouse to the right edge of the screen crossing the light bar
988 // should show the shelf despite the mouse cursor getting warped to the 993 // should show the shelf despite the mouse cursor getting warped to the
989 // secondary display. 994 // secondary display.
990 generator.MoveMouseTo(right_edge - 1, y); 995 generator.MoveMouseTo(right_edge - 1, y);
991 generator.MoveMouseTo(right_edge, y); 996 generator.MoveMouseTo(right_edge, y);
992 UpdateAutoHideStateNow(); 997 UpdateAutoHideStateNow();
993 EXPECT_NE(right_edge - 1, Shell::GetScreen()->GetCursorScreenPoint().x()); 998 EXPECT_NE(right_edge - 1,
999 gfx::Screen::GetScreen()->GetCursorScreenPoint().x());
994 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 1000 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
995 1001
996 // Hide the shelf. 1002 // Hide the shelf.
997 generator.MoveMouseTo(right_edge - 50, y); 1003 generator.MoveMouseTo(right_edge - 50, y);
998 UpdateAutoHideStateNow(); 1004 UpdateAutoHideStateNow();
999 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 1005 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
1000 1006
1001 // Moving the mouse to the right edge of the screen crossing the light bar and 1007 // Moving the mouse to the right edge of the screen crossing the light bar and
1002 // overshooting by a lot should keep the shelf hidden. 1008 // overshooting by a lot should keep the shelf hidden.
1003 generator.MoveMouseTo(right_edge - 1, y); 1009 generator.MoveMouseTo(right_edge - 1, y);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1102 ShelfLayoutManager* shelf = GetShelfLayoutManager();
1097 views::Widget* widget = new views::Widget; 1103 views::Widget* widget = new views::Widget;
1098 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 1104 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
1099 params.bounds = gfx::Rect(0, 0, 200, 200); 1105 params.bounds = gfx::Rect(0, 0, 200, 200);
1100 params.context = CurrentContext(); 1106 params.context = CurrentContext();
1101 // Widget is now owned by the parent window. 1107 // Widget is now owned by the parent window.
1102 widget->Init(params); 1108 widget->Init(params);
1103 widget->Show(); 1109 widget->Show();
1104 aura::Window* window = widget->GetNativeWindow(); 1110 aura::Window* window = widget->GetNativeWindow();
1105 gfx::Rect display_bounds( 1111 gfx::Rect display_bounds(
1106 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); 1112 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds());
1107 1113
1108 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1114 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1109 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 1115 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
1110 1116
1111 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1117 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1112 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1118 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1113 1119
1114 widget->Maximize(); 1120 widget->Maximize();
1115 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1121 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1116 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( 1122 EXPECT_EQ(gfx::Screen::GetScreen()
1117 window).work_area().bottom(), 1123 ->GetDisplayNearestWindow(window)
1124 .work_area()
1125 .bottom(),
1118 widget->GetWorkAreaBoundsInScreen().bottom()); 1126 widget->GetWorkAreaBoundsInScreen().bottom());
1119 1127
1120 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1128 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1121 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 1129 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
1122 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( 1130 EXPECT_EQ(gfx::Screen::GetScreen()
1123 window).work_area().bottom(), 1131 ->GetDisplayNearestWindow(window)
1132 .work_area()
1133 .bottom(),
1124 widget->GetWorkAreaBoundsInScreen().bottom()); 1134 widget->GetWorkAreaBoundsInScreen().bottom());
1125 1135
1126 ui::ScopedAnimationDurationScaleMode animation_duration( 1136 ui::ScopedAnimationDurationScaleMode animation_duration(
1127 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); 1137 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION);
1128 1138
1129 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1139 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1130 ShelfWidget* shelf_widget = GetShelfWidget(); 1140 ShelfWidget* shelf_widget = GetShelfWidget();
1131 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible()); 1141 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible());
1132 StepWidgetLayerAnimatorToEnd(shelf_widget); 1142 StepWidgetLayerAnimatorToEnd(shelf_widget);
1133 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); 1143 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget());
1134 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1144 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1135 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( 1145 EXPECT_EQ(gfx::Screen::GetScreen()
1136 window).work_area().bottom(), 1146 ->GetDisplayNearestWindow(window)
1147 .work_area()
1148 .bottom(),
1137 widget->GetWorkAreaBoundsInScreen().bottom()); 1149 widget->GetWorkAreaBoundsInScreen().bottom());
1138 } 1150 }
1139 1151
1140 // Basic assertions around the dimming of the shelf. 1152 // Basic assertions around the dimming of the shelf.
1141 TEST_F(ShelfLayoutManagerTest, DimmingBehavior) { 1153 TEST_F(ShelfLayoutManagerTest, DimmingBehavior) {
1142 // Since ShelfLayoutManager queries for mouse location, move the mouse so 1154 // Since ShelfLayoutManager queries for mouse location, move the mouse so
1143 // it isn't over the shelf. 1155 // it isn't over the shelf.
1144 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 1156 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
1145 gfx::Point()); 1157 gfx::Point());
1146 generator.MoveMouseTo(0, 0); 1158 generator.MoveMouseTo(0, 0);
1147 1159
1148 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1160 ShelfLayoutManager* shelf = GetShelfLayoutManager();
1149 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); 1161 shelf->shelf_widget()->DisableDimmingAnimationsForTest();
1150 1162
1151 views::Widget* widget = new views::Widget; 1163 views::Widget* widget = new views::Widget;
1152 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 1164 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
1153 params.bounds = gfx::Rect(0, 0, 200, 200); 1165 params.bounds = gfx::Rect(0, 0, 200, 200);
1154 params.context = CurrentContext(); 1166 params.context = CurrentContext();
1155 // Widget is now owned by the parent window. 1167 // Widget is now owned by the parent window.
1156 widget->Init(params); 1168 widget->Init(params);
1157 widget->Show(); 1169 widget->Show();
1158 aura::Window* window = widget->GetNativeWindow(); 1170 aura::Window* window = widget->GetNativeWindow();
1159 gfx::Rect display_bounds( 1171 gfx::Rect display_bounds(
1160 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); 1172 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds());
1161 1173
1162 gfx::Point off_shelf = display_bounds.CenterPoint(); 1174 gfx::Point off_shelf = display_bounds.CenterPoint();
1163 gfx::Point on_shelf = 1175 gfx::Point on_shelf =
1164 shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint(); 1176 shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint();
1165 1177
1166 // Test there is no dimming object active at this point. 1178 // Test there is no dimming object active at this point.
1167 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); 1179 generator.MoveMouseTo(on_shelf.x(), on_shelf.y());
1168 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); 1180 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest());
1169 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); 1181 generator.MoveMouseTo(off_shelf.x(), off_shelf.y());
1170 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); 1182 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 1293
1282 views::Widget* widget = new views::Widget; 1294 views::Widget* widget = new views::Widget;
1283 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 1295 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
1284 params.bounds = gfx::Rect(0, 0, 200, 200); 1296 params.bounds = gfx::Rect(0, 0, 200, 200);
1285 params.context = CurrentContext(); 1297 params.context = CurrentContext();
1286 // Widget is now owned by the parent window. 1298 // Widget is now owned by the parent window.
1287 widget->Init(params); 1299 widget->Init(params);
1288 widget->Show(); 1300 widget->Show();
1289 aura::Window* window = widget->GetNativeWindow(); 1301 aura::Window* window = widget->GetNativeWindow();
1290 gfx::Rect display_bounds( 1302 gfx::Rect display_bounds(
1291 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); 1303 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds());
1292 1304
1293 // After maximization, the shelf should be visible and the dimmer created. 1305 // After maximization, the shelf should be visible and the dimmer created.
1294 widget->Maximize(); 1306 widget->Maximize();
1295 1307
1296 gfx::Point off_shelf = display_bounds.CenterPoint(); 1308 gfx::Point off_shelf = display_bounds.CenterPoint();
1297 gfx::Point on_shelf = 1309 gfx::Point on_shelf =
1298 shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint(); 1310 shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint();
1299 1311
1300 // Moving the mouse on the shelf should undim the bar. 1312 // Moving the mouse on the shelf should undim the bar.
1301 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); 1313 generator.MoveMouseTo(on_shelf.x(), on_shelf.y());
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { 1719 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) {
1708 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1720 ShelfLayoutManager* shelf = GetShelfLayoutManager();
1709 // Force an initial layout. 1721 // Force an initial layout.
1710 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1722 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1711 shelf->LayoutShelf(); 1723 shelf->LayoutShelf();
1712 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1724 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1713 1725
1714 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 1726 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
1715 gfx::Rect shelf_bounds( 1727 gfx::Rect shelf_bounds(
1716 GetShelfWidget()->GetWindowBoundsInScreen()); 1728 GetShelfWidget()->GetWindowBoundsInScreen());
1717 const gfx::Screen* screen = Shell::GetScreen(); 1729 const gfx::Screen* screen = gfx::Screen::GetScreen();
1718 gfx::Display display = 1730 gfx::Display display =
1719 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); 1731 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
1720 ASSERT_NE(-1, display.id()); 1732 ASSERT_NE(-1, display.id());
1721 EXPECT_EQ(shelf->GetIdealBounds().width(), 1733 EXPECT_EQ(shelf->GetIdealBounds().width(),
1722 display.GetWorkAreaInsets().left()); 1734 display.GetWorkAreaInsets().left());
1723 EXPECT_GE( 1735 EXPECT_GE(
1724 shelf_bounds.width(), 1736 shelf_bounds.width(),
1725 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); 1737 GetShelfWidget()->GetContentsView()->GetPreferredSize().width());
1726 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); 1738 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment());
1727 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); 1739 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget();
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 StatusAreaWidget* status_area_widget = 2368 StatusAreaWidget* status_area_widget =
2357 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); 2369 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget();
2358 EXPECT_TRUE(status_area_widget->IsVisible()); 2370 EXPECT_TRUE(status_area_widget->IsVisible());
2359 // Shelf should be in the first display's area. 2371 // Shelf should be in the first display's area.
2360 // TODO: make this test more robust against changes in font, font size. 2372 // TODO: make this test more robust against changes in font, font size.
2361 EXPECT_EQ("353,453 147x47", 2373 EXPECT_EQ("353,453 147x47",
2362 status_area_widget->GetWindowBoundsInScreen().ToString()); 2374 status_area_widget->GetWindowBoundsInScreen().ToString());
2363 } 2375 }
2364 2376
2365 } // namespace ash 2377 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.cc ('k') | ash/shelf/shelf_window_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698