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

Unified Diff: ash/shelf/shelf_layout_manager_unittest.cc

Issue 2017413002: ash: Fix variable names and setters in ShelfLayoutManager and tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shellshelf
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
Index: ash/shelf/shelf_layout_manager_unittest.cc
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index 5dba0a9ec53d10403b51c39eb16a340d26fa807c..5ee2324f222124546e6f1570a8296444e1036387 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -59,6 +59,10 @@ void StepWidgetLayerAnimatorToEnd(views::Widget* widget) {
base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
}
+Shelf* GetShelf() {
+ return Shelf::ForPrimaryDisplay();
+}
+
ShelfWidget* GetShelfWidget() {
return Shell::GetPrimaryRootWindowController()->shelf_widget();
msw 2016/06/01 00:53:24 optional nit: return GetShelf()->shelf_widget();?
James Cook 2016/06/01 15:53:06 Done.
}
@@ -320,9 +324,9 @@ class ShelfLayoutManagerTest : public ash::test::AshTestBase {
public:
ShelfLayoutManagerTest() {}
- void SetState(ShelfLayoutManager* shelf,
+ void SetState(ShelfLayoutManager* layout_manager,
msw 2016/06/01 00:53:24 nit: remove this and inline ShelfLayoutManager::Se
James Cook 2016/06/01 15:53:06 ShelfLayoutManager::SetState() is private, so inli
msw 2016/06/01 17:30:07 Acknowledged.
ShelfVisibilityState state) {
- shelf->SetState(state);
+ layout_manager->SetState(state);
}
void UpdateAutoHideStateNow() {
@@ -385,7 +389,7 @@ class ShelfLayoutManagerTest : public ash::test::AshTestBase {
};
void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
+ Shelf* shelf = GetShelf();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
@@ -399,21 +403,22 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
const base::TimeDelta kTimeDelta = base::TimeDelta::FromMilliseconds(100);
aura::Window* window = widget->GetNativeWindow();
- shelf->LayoutShelf();
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ layout_manager->LayoutShelf();
gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen();
gfx::Rect bounds_shelf = window->bounds();
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- shelf->LayoutShelf();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ layout_manager->LayoutShelf();
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
gfx::Rect bounds_noshelf = window->bounds();
gfx::Rect shelf_hidden = GetShelfWidget()->GetWindowBoundsInScreen();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
- shelf->LayoutShelf();
+ layout_manager->LayoutShelf();
ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
const int kNumScrollSteps = 4;
@@ -431,8 +436,8 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_NE(bounds_shelf.ToString(), window->bounds().ToString());
EXPECT_NE(shelf_shown.ToString(),
@@ -446,7 +451,7 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString());
EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(),
@@ -463,8 +468,8 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(shelf_hidden.ToString(),
GetShelfWidget()->GetWindowBoundsInScreen().ToString());
@@ -487,7 +492,7 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
else if (wm::SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment())
end.set_x(start.x() + shelf_shown.width() * 3 / 10);
generator.GestureScrollSequence(start, end, kTimeDelta, 5);
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString());
EXPECT_EQ(shelf_shown.ToString(),
@@ -502,8 +507,8 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect());
EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString());
@@ -527,7 +532,7 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString());
EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(),
@@ -544,8 +549,8 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect());
EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString());
@@ -560,8 +565,8 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
end = outside_start + delta;
generator.GestureScrollSequence(
outside_start, end, kTimeDelta, kNumScrollSteps);
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(shelf_hidden.ToString(),
GetShelfWidget()->GetWindowBoundsInScreen().ToString());
@@ -579,7 +584,7 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
end = below_start - delta;
generator.GestureScrollSequence(
below_start, end, kTimeDelta, kNumScrollSteps);
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString());
EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(),
@@ -596,8 +601,8 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect());
EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString());
@@ -608,7 +613,7 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
// is fullscreen. (eg browser immersive fullscreen).
widget->SetFullscreen(true);
wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false);
- shelf->UpdateVisibilityState();
+ layout_manager->UpdateVisibilityState();
gfx::Rect bounds_fullscreen = window->bounds();
EXPECT_TRUE(widget->IsFullscreen());
@@ -623,8 +628,8 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
EXPECT_EQ(shelf_shown.ToString(),
GetShelfWidget()->GetWindowBoundsInScreen().ToString());
@@ -638,8 +643,8 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(shelf_hidden.ToString(),
GetShelfWidget()->GetWindowBoundsInScreen().ToString());
@@ -648,8 +653,8 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
// Set the shelf to be hidden when |widget| is fullscreen. (eg tab fullscreen
// with or without immersive browser fullscreen).
wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(true);
- shelf->UpdateVisibilityState();
- EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
+ layout_manager->UpdateVisibilityState();
+ EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
// Swipe-up. This should not change anything.
@@ -661,7 +666,7 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));
- EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
+ EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString());
@@ -671,8 +676,8 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
RunAllPendingInMessageLoop();
// The shelf should be shown because there are no more visible windows.
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
// Swipe-up to hide. This should have no effect because there are no visible
@@ -685,8 +690,8 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
}
@@ -698,16 +703,15 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
#endif
// Makes sure SetVisible updates work area and widget appropriately.
TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) {
- ShelfWidget* shelf = GetShelfWidget();
- ShelfLayoutManager* manager = shelf->shelf_layout_manager();
+ ShelfWidget* shelf_widget = GetShelfWidget();
+ ShelfLayoutManager* manager = shelf_widget->shelf_layout_manager();
// Force an initial layout.
manager->LayoutShelf();
EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state());
gfx::Rect status_bounds(
- shelf->status_area_widget()->GetWindowBoundsInScreen());
- gfx::Rect shelf_bounds(
- shelf->GetWindowBoundsInScreen());
+ shelf_widget->status_area_widget()->GetWindowBoundsInScreen());
+ gfx::Rect shelf_bounds(shelf_widget->GetWindowBoundsInScreen());
int shelf_height = manager->GetIdealBounds().height();
display::Screen* screen = display::Screen::GetScreen();
display::Display display =
@@ -719,8 +723,8 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) {
// Hide the shelf.
SetState(manager, SHELF_HIDDEN);
// Run the animation to completion.
- StepWidgetLayerAnimatorToEnd(shelf);
- StepWidgetLayerAnimatorToEnd(shelf->status_area_widget());
+ StepWidgetLayerAnimatorToEnd(shelf_widget);
+ StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget());
EXPECT_EQ(SHELF_HIDDEN, manager->visibility_state());
display = screen->GetDisplayNearestWindow(
Shell::GetPrimaryRootWindow());
@@ -728,71 +732,73 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) {
EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
// Make sure the bounds of the two widgets changed.
- EXPECT_GE(shelf->GetNativeView()->bounds().y(),
+ EXPECT_GE(shelf_widget->GetNativeView()->bounds().y(),
screen->GetPrimaryDisplay().bounds().bottom());
- EXPECT_GE(shelf->status_area_widget()->GetNativeView()->bounds().y(),
+ EXPECT_GE(shelf_widget->status_area_widget()->GetNativeView()->bounds().y(),
screen->GetPrimaryDisplay().bounds().bottom());
// And show it again.
SetState(manager, SHELF_VISIBLE);
// Run the animation to completion.
- StepWidgetLayerAnimatorToEnd(shelf);
- StepWidgetLayerAnimatorToEnd(shelf->status_area_widget());
+ StepWidgetLayerAnimatorToEnd(shelf_widget);
+ StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget());
EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state());
display = screen->GetDisplayNearestWindow(
Shell::GetPrimaryRootWindow());
EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom());
// Make sure the bounds of the two widgets changed.
- shelf_bounds = shelf->GetNativeView()->bounds();
+ shelf_bounds = shelf_widget->GetNativeView()->bounds();
EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom());
- status_bounds = shelf->status_area_widget()->GetNativeView()->bounds();
+ status_bounds = shelf_widget->status_area_widget()->GetNativeView()->bounds();
EXPECT_LT(status_bounds.y(),
screen->GetPrimaryDisplay().bounds().bottom());
}
// Makes sure LayoutShelf invoked while animating cleans things up.
TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
- ShelfWidget* shelf = GetShelfWidget();
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
// Force an initial layout.
- shelf->shelf_layout_manager()->LayoutShelf();
- EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state());
+ layout_manager->LayoutShelf();
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
// Hide the shelf.
- SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN);
- shelf->shelf_layout_manager()->LayoutShelf();
- EXPECT_EQ(SHELF_HIDDEN, shelf->shelf_layout_manager()->visibility_state());
+ SetState(layout_manager, SHELF_HIDDEN);
+ layout_manager->LayoutShelf();
+ EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state());
display::Display display =
display::Screen::GetScreen()->GetDisplayNearestWindow(
Shell::GetPrimaryRootWindow());
EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
// Make sure the bounds of the two widgets changed.
+ ShelfWidget* shelf_widget = GetShelfWidget();
EXPECT_GE(
- shelf->GetNativeView()->bounds().y(),
+ shelf_widget->GetNativeView()->bounds().y(),
display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom());
EXPECT_GE(
- shelf->status_area_widget()->GetNativeView()->bounds().y(),
+ shelf_widget->status_area_widget()->GetNativeView()->bounds().y(),
display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom());
}
// Test that switching to a different visibility state does not restart the
// shelf show / hide animation if it is already running. (crbug.com/250918)
TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) {
- ShelfWidget* shelf = GetShelfWidget();
- SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE);
- gfx::Rect initial_shelf_bounds = shelf->GetWindowBoundsInScreen();
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ SetState(layout_manager, SHELF_VISIBLE);
+ ShelfWidget* shelf_widget = GetShelfWidget();
+ gfx::Rect initial_shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
gfx::Rect initial_status_bounds =
- shelf->status_area_widget()->GetWindowBoundsInScreen();
+ shelf_widget->status_area_widget()->GetWindowBoundsInScreen();
ui::ScopedAnimationDurationScaleMode normal_animation_duration(
ui::ScopedAnimationDurationScaleMode::SLOW_DURATION);
- SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN);
- SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE);
+ SetState(layout_manager, SHELF_HIDDEN);
+ SetState(layout_manager, SHELF_VISIBLE);
- gfx::Rect current_shelf_bounds = shelf->GetWindowBoundsInScreen();
+ gfx::Rect current_shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
gfx::Rect current_status_bounds =
- shelf->status_area_widget()->GetWindowBoundsInScreen();
+ shelf_widget->status_area_widget()->GetWindowBoundsInScreen();
const int small_change = initial_shelf_bounds.height() / 2;
EXPECT_LE(
@@ -805,7 +811,7 @@ TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) {
// Makes sure the shelf is sized when the status area changes size.
TEST_F(ShelfLayoutManagerTest, ShelfUpdatedWhenStatusAreaChangesSize) {
- Shelf* shelf = Shelf::ForPrimaryDisplay();
+ Shelf* shelf = GetShelf();
ASSERT_TRUE(shelf);
ShelfWidget* shelf_widget = GetShelfWidget();
ASSERT_TRUE(shelf_widget);
@@ -830,8 +836,8 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) {
ui::test::EventGenerator generator(root, root);
generator.MoveMouseTo(0, 0);
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ GetShelf()->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 200, 200);
@@ -840,12 +846,12 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) {
widget->Init(params);
widget->Maximize();
widget->Show();
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// LayoutShelf() forces the animation to completion, at which point the
// shelf should go off the screen.
- shelf->LayoutShelf();
+ layout_manager->LayoutShelf();
EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
GetShelfWidget()->GetWindowBoundsInScreen().y());
EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
@@ -858,10 +864,10 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) {
generator.MoveMouseTo(0, root->bounds().bottom() - 1);
// Shelf should be shown again (but it shouldn't have changed the work area).
- SetState(shelf, SHELF_AUTO_HIDE);
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
- shelf->LayoutShelf();
- EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(),
+ SetState(layout_manager, SHELF_AUTO_HIDE);
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
+ layout_manager->LayoutShelf();
+ EXPECT_EQ(root->bounds().bottom() - layout_manager->GetIdealBounds().height(),
GetShelfWidget()->GetWindowBoundsInScreen().y());
EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
display::Screen::GetScreen()
@@ -871,9 +877,9 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) {
// Move mouse back up.
generator.MoveMouseTo(0, 0);
- SetState(shelf, SHELF_AUTO_HIDE);
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
- shelf->LayoutShelf();
+ SetState(layout_manager, SHELF_AUTO_HIDE);
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
+ layout_manager->LayoutShelf();
EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
GetShelfWidget()->GetWindowBoundsInScreen().y());
@@ -881,16 +887,16 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) {
generator.PressLeftButton();
generator.MoveMouseTo(0, root->bounds().bottom() - 1);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
generator.ReleaseLeftButton();
generator.MoveMouseTo(1, root->bounds().bottom() - 1);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
generator.PressLeftButton();
generator.MoveMouseTo(1, root->bounds().bottom() - 1);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
}
// Test the behavior of the shelf when it is auto hidden and it is on the
@@ -903,8 +909,8 @@ TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) {
Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 0));
// Put the primary monitor's shelf on the display boundary.
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ GetShelf()->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
// Create a window because the shelf is always shown when no windows are
// visible.
@@ -914,8 +920,8 @@ TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) {
ASSERT_EQ(root_windows[0],
GetShelfWidget()->GetNativeWindow()->GetRootWindow());
- shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ GetShelf()->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
int right_edge = root_windows[0]->GetBoundsInScreen().right() - 1;
int y = root_windows[0]->GetBoundsInScreen().y();
@@ -924,20 +930,20 @@ TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) {
ui::test::EventGenerator& generator(GetEventGenerator());
generator.MoveMouseTo(right_edge - 50, y);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// Moving the mouse over the light bar (but not to the edge of the screen)
// should show the shelf.
generator.MoveMouseTo(right_edge - 1, y);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
EXPECT_EQ(right_edge - 1,
display::Screen::GetScreen()->GetCursorScreenPoint().x());
// Moving the mouse off the light bar should hide the shelf.
generator.MoveMouseTo(right_edge - 50, y);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// Moving the mouse to the right edge of the screen crossing the light bar
// should show the shelf despite the mouse cursor getting warped to the
@@ -947,44 +953,44 @@ TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) {
UpdateAutoHideStateNow();
EXPECT_NE(right_edge - 1,
display::Screen::GetScreen()->GetCursorScreenPoint().x());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
// Hide the shelf.
generator.MoveMouseTo(right_edge - 50, y);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// Moving the mouse to the right edge of the screen crossing the light bar and
// overshooting by a lot should keep the shelf hidden.
generator.MoveMouseTo(right_edge - 1, y);
generator.MoveMouseTo(right_edge + 50, y);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// Moving the mouse to the right edge of the screen crossing the light bar and
// overshooting a bit should show the shelf.
generator.MoveMouseTo(right_edge - 1, y);
generator.MoveMouseTo(right_edge + 2, y);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
// Keeping the mouse close to the left edge of the secondary display after the
// shelf is shown should keep the shelf shown.
generator.MoveMouseTo(right_edge + 2, y + 1);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
// Moving the mouse far from the left edge of the secondary display should
// hide the shelf.
generator.MoveMouseTo(right_edge + 50, y);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// Moving to the left edge of the secondary display without first crossing
// the primary display's right aligned shelf first should not show the shelf.
generator.MoveMouseTo(right_edge + 2, y);
UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
}
// Assertions around the lock screen showing.
@@ -998,8 +1004,8 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
gfx::Point());
generator.MoveMouseTo(0, 0);
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ GetShelf()->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 200, 200);
@@ -1008,13 +1014,13 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
widget->Init(params);
widget->Maximize();
widget->Show();
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
aura::Window* root = Shell::GetPrimaryRootWindow();
// LayoutShelf() forces the animation to completion, at which point the
// shelf should go off the screen.
- shelf->LayoutShelf();
+ layout_manager->LayoutShelf();
EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
GetShelfWidget()->GetWindowBoundsInScreen().y());
@@ -1035,10 +1041,10 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
// Lock the screen.
LockScreen();
// Showing a widget in the lock screen should force the shelf to be visibile.
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
UnlockScreen();
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
}
// Assertions around SetAutoHideBehavior.
@@ -1049,7 +1055,7 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
gfx::Point());
generator.MoveMouseTo(0, 0);
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 200, 200);
@@ -1061,14 +1067,15 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
gfx::Rect display_bounds(
display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds());
+ Shelf* shelf = GetShelf();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
widget->Maximize();
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
EXPECT_EQ(display::Screen::GetScreen()
->GetDisplayNearestWindow(window)
.work_area()
@@ -1076,7 +1083,7 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
widget->GetWorkAreaBoundsInScreen().bottom());
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
EXPECT_EQ(display::Screen::GetScreen()
->GetDisplayNearestWindow(window)
.work_area()
@@ -1091,7 +1098,7 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible());
StepWidgetLayerAnimatorToEnd(shelf_widget);
StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget());
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
EXPECT_EQ(display::Screen::GetScreen()
->GetDisplayNearestWindow(window)
.work_area()
@@ -1107,8 +1114,8 @@ TEST_F(ShelfLayoutManagerTest, DimmingBehavior) {
gfx::Point());
generator.MoveMouseTo(0, 0);
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->shelf_widget()->DisableDimmingAnimationsForTest();
+ ShelfWidget* shelf_widget = GetShelfWidget();
+ shelf_widget->DisableDimmingAnimationsForTest();
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
@@ -1122,55 +1129,54 @@ TEST_F(ShelfLayoutManagerTest, DimmingBehavior) {
display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds());
gfx::Point off_shelf = display_bounds.CenterPoint();
- gfx::Point on_shelf =
- shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint();
+ gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint();
// Test there is no dimming object active at this point.
generator.MoveMouseTo(on_shelf.x(), on_shelf.y());
- EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest());
generator.MoveMouseTo(off_shelf.x(), off_shelf.y());
- EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest());
// After maximization, the shelf should be visible and the dimmer created.
widget->Maximize();
- on_shelf = shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint();
- EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint();
+ EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest());
// Moving the mouse off the shelf should dim the bar.
generator.MoveMouseTo(off_shelf.x(), off_shelf.y());
- EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest());
// Adding touch events outside the shelf should still keep the shelf in
// dimmed state.
generator.PressTouch();
generator.MoveTouch(off_shelf);
- EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest());
// Move the touch into the shelf area should undim.
generator.MoveTouch(on_shelf);
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
generator.ReleaseTouch();
// And a release dims again.
- EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest());
// Moving the mouse on the shelf should undim the bar.
generator.MoveMouseTo(on_shelf);
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
// No matter what the touch events do, the shelf should stay undimmed.
generator.PressTouch();
generator.MoveTouch(off_shelf);
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
generator.MoveTouch(on_shelf);
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
generator.MoveTouch(off_shelf);
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
generator.MoveTouch(on_shelf);
generator.ReleaseTouch();
// After restore, the dimming object should be deleted again.
widget->Restore();
- EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest());
}
// Test that dimming works correctly with multiple displays.
@@ -1238,8 +1244,8 @@ TEST_F(ShelfLayoutManagerTest, DimmingBehaviorWithMenus) {
gfx::Point());
generator.MoveMouseTo(0, 0);
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->shelf_widget()->DisableDimmingAnimationsForTest();
+ ShelfWidget* shelf_widget = GetShelfWidget();
+ shelf_widget->DisableDimmingAnimationsForTest();
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
@@ -1256,48 +1262,47 @@ TEST_F(ShelfLayoutManagerTest, DimmingBehaviorWithMenus) {
widget->Maximize();
gfx::Point off_shelf = display_bounds.CenterPoint();
- gfx::Point on_shelf =
- shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint();
+ gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint();
// Moving the mouse on the shelf should undim the bar.
generator.MoveMouseTo(on_shelf.x(), on_shelf.y());
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
// Simulate a menu opening.
- shelf->shelf_widget()->ForceUndimming(true);
+ shelf_widget->ForceUndimming(true);
// Moving the mouse off the shelf should not dim the bar.
generator.MoveMouseTo(off_shelf.x(), off_shelf.y());
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
// No matter what the touch events do, the shelf should stay undimmed.
generator.PressTouch();
generator.MoveTouch(off_shelf);
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
generator.MoveTouch(on_shelf);
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
generator.MoveTouch(off_shelf);
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
generator.ReleaseTouch();
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
// "Closing the menu" should now turn off the menu since no event is inside
// the shelf any longer.
- shelf->shelf_widget()->ForceUndimming(false);
- EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ shelf_widget->ForceUndimming(false);
+ EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest());
// Moving the mouse again on the shelf which should undim the bar again.
// This time we check that the bar stays undimmed when the mouse remains on
// the bar and the "menu gets closed".
generator.MoveMouseTo(on_shelf.x(), on_shelf.y());
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
- shelf->shelf_widget()->ForceUndimming(true);
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
+ shelf_widget->ForceUndimming(true);
generator.MoveMouseTo(off_shelf.x(), off_shelf.y());
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
generator.MoveMouseTo(on_shelf.x(), on_shelf.y());
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
- shelf->shelf_widget()->ForceUndimming(true);
- EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
+ shelf_widget->ForceUndimming(true);
+ EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
}
// Verifies the shelf is visible when status/shelf is focused.
@@ -1308,7 +1313,7 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) {
gfx::Point());
generator.MoveMouseTo(0, 0);
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 200, 200);
@@ -1316,25 +1321,25 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) {
// Widget is now owned by the parent window.
widget->Init(params);
widget->Show();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// Focus the shelf. Have to go through the focus cycler as normal focus
// requests to it do nothing.
GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
widget->Activate();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// Trying to activate the status should fail, since we only allow activating
// it when the user is using the keyboard (i.e. through FocusCycler).
GetShelfWidget()->status_area_widget()->Activate();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
}
// Makes sure shelf will be visible when app list opens as shelf is in
@@ -1342,26 +1347,26 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) {
// visibility state.
TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
Shell* shell = Shell::GetInstance();
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->LayoutShelf();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ layout_manager->LayoutShelf();
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
// Create a normal unmaximized windowm shelf should be visible.
aura::Window* window = CreateTestWindow();
window->SetBounds(gfx::Rect(0, 0, 100, 100));
window->Show();
EXPECT_FALSE(shell->GetAppListTargetVisibility());
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
// Show app list and the shelf stays visible.
shell->ShowAppList(nullptr);
EXPECT_TRUE(shell->GetAppListTargetVisibility());
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
// Hide app list and the shelf stays visible.
shell->DismissAppList();
EXPECT_FALSE(shell->GetAppListTargetVisibility());
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
}
// Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state
@@ -1369,9 +1374,9 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
// toggling app list won't change shelf visibility state.
TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
Shell* shell = Shell::GetInstance();
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->LayoutShelf();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ layout_manager->LayoutShelf();
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
// Create a window and show it in maximized state.
aura::Window* window = CreateTestWindow();
@@ -1381,7 +1386,7 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
wm::ActivateWindow(window);
EXPECT_FALSE(shell->GetAppListTargetVisibility());
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
// Show app list.
shell->ShowAppList(nullptr);
@@ -1390,13 +1395,13 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
// update the state.
shell->UpdateShelfVisibility();
EXPECT_TRUE(shell->GetAppListTargetVisibility());
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
// Hide app list.
shell->DismissAppList();
EXPECT_FALSE(shell->GetAppListTargetVisibility());
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
}
// Makes sure that when we have dual displays, with one or both shelves are set
@@ -1427,9 +1432,11 @@ TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) {
EXPECT_NE(shelf_1, shelf_2);
EXPECT_NE(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(),
shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow());
- shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ shelf_1->shelf_widget()->shelf()->SetAutoHideBehavior(
+ SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
shelf_1->LayoutShelf();
- shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ shelf_2->shelf_widget()->shelf()->SetAutoHideBehavior(
+ SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
shelf_2->LayoutShelf();
// Create a window in each display and show them in maximized state.
@@ -1482,9 +1489,9 @@ TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) {
// will unhide when we open the app list.
TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) {
Shell* shell = Shell::GetInstance();
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
// For shelf to be visible, app list is not open in initial state.
- shelf->LayoutShelf();
+ layout_manager->LayoutShelf();
// Create a window and make it full screen.
aura::Window* window = CreateTestWindow();
@@ -1495,26 +1502,26 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) {
// App list and shelf is not shown.
EXPECT_FALSE(shell->GetAppListTargetVisibility());
- EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
+ EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state());
// Show app list.
shell->ShowAppList(nullptr);
EXPECT_TRUE(shell->GetAppListTargetVisibility());
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
// Hide app list.
shell->DismissAppList();
EXPECT_FALSE(shell->GetAppListTargetVisibility());
- EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
+ EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state());
}
// Tests the correct behavior of the shelf when there is a system modal window
// open when we have a single display.
TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowSingleDisplay) {
Shell* shell = Shell::GetInstance();
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->LayoutShelf();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ layout_manager->LayoutShelf();
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
aura::Window* window = CreateTestWindow();
window->SetBounds(gfx::Rect(0, 0, 100, 100));
@@ -1527,8 +1534,8 @@ TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowSingleDisplay) {
EXPECT_TRUE(shell->IsSystemModalWindowOpen());
EXPECT_FALSE(wm::CanActivateWindow(window));
shell->UpdateShelfVisibility();
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
}
// Tests the correct behavior of the shelf when there is a system modal window
@@ -1550,17 +1557,20 @@ TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) {
EXPECT_EQ(2U, root_windows.size());
// Get the shelves in both displays and set them to be 'AutoHide'.
- ShelfLayoutManager* shelf_1 =
+ Shelf* shelf_1 = GetRootWindowController(root_windows[0])->GetShelf();
+ Shelf* shelf_2 = GetRootWindowController(root_windows[1])->GetShelf();
+ ShelfLayoutManager* layout_manager_1 =
GetRootWindowController(root_windows[0])->GetShelfLayoutManager();
- ShelfLayoutManager* shelf_2 =
+ ShelfLayoutManager* layout_manager_2 =
GetRootWindowController(root_windows[1])->GetShelfLayoutManager();
- EXPECT_NE(shelf_1, shelf_2);
- EXPECT_NE(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(),
- shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow());
+ EXPECT_NE(layout_manager_1, layout_manager_2);
+ EXPECT_NE(
+ layout_manager_1->shelf_widget()->GetNativeWindow()->GetRootWindow(),
+ layout_manager_2->shelf_widget()->GetNativeWindow()->GetRootWindow());
shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- shelf_1->LayoutShelf();
+ layout_manager_1->LayoutShelf();
shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- shelf_2->LayoutShelf();
+ layout_manager_2->LayoutShelf();
// Create a window in each display and show them in maximized state.
aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]);
@@ -1572,10 +1582,12 @@ TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) {
window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
window_2->Show();
- EXPECT_EQ(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(),
- window_1->GetRootWindow());
- EXPECT_EQ(shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow(),
- window_2->GetRootWindow());
+ EXPECT_EQ(
+ layout_manager_1->shelf_widget()->GetNativeWindow()->GetRootWindow(),
+ window_1->GetRootWindow());
+ EXPECT_EQ(
+ layout_manager_2->shelf_widget()->GetNativeWindow()->GetRootWindow(),
+ window_2->GetRootWindow());
EXPECT_TRUE(window_1->IsVisible());
EXPECT_TRUE(window_2->IsVisible());
@@ -1585,16 +1597,16 @@ TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) {
EXPECT_FALSE(wm::CanActivateWindow(window_1));
EXPECT_FALSE(wm::CanActivateWindow(window_2));
shell->UpdateShelfVisibility();
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->auto_hide_state());
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager_1->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager_1->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager_2->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager_2->auto_hide_state());
}
// Tests that the shelf is only hidden for a fullscreen window at the front and
// toggles visibility when another window is activated.
TEST_F(ShelfLayoutManagerTest, FullscreenWindowInFrontHidesShelf) {
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
// Create a window and make it full screen.
aura::Window* window1 = CreateTestWindow();
@@ -1607,13 +1619,13 @@ TEST_F(ShelfLayoutManagerTest, FullscreenWindowInFrontHidesShelf) {
window2->Show();
wm::GetWindowState(window1)->Activate();
- EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
+ EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state());
wm::GetWindowState(window2)->Activate();
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
wm::GetWindowState(window1)->Activate();
- EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
+ EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state());
}
// Test the behavior of the shelf when a window on one display is fullscreen
@@ -1662,20 +1674,20 @@ TEST_F(ShelfLayoutManagerTest, FullscreenWindowOnSecondDisplay) {
// Tests wm::SHELF_ALIGNMENT_(LEFT, RIGHT).
TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) {
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
// Force an initial layout.
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
- shelf->LayoutShelf();
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ layout_manager->LayoutShelf();
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
- shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
+ GetShelf()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
gfx::Rect shelf_bounds(
GetShelfWidget()->GetWindowBoundsInScreen());
const display::Screen* screen = display::Screen::GetScreen();
display::Display display =
screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
ASSERT_NE(-1, display.id());
- EXPECT_EQ(shelf->GetIdealBounds().width(),
+ EXPECT_EQ(layout_manager->GetIdealBounds().width(),
display.GetWorkAreaInsets().left());
EXPECT_GE(
shelf_bounds.width(),
@@ -1685,7 +1697,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) {
gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen());
EXPECT_GE(status_bounds.width(),
status_area_widget->GetContentsView()->GetPreferredSize().width());
- EXPECT_EQ(shelf->GetIdealBounds().width(),
+ EXPECT_EQ(layout_manager->GetIdealBounds().width(),
display.GetWorkAreaInsets().left());
EXPECT_EQ(0, display.GetWorkAreaInsets().top());
EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
@@ -1693,19 +1705,19 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) {
EXPECT_EQ(display.bounds().x(), shelf_bounds.x());
EXPECT_EQ(display.bounds().y(), shelf_bounds.y());
EXPECT_EQ(display.bounds().height(), shelf_bounds.height());
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
EXPECT_EQ(ShelfLayoutManager::kAutoHideSize,
display.GetWorkAreaInsets().left());
EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, display.work_area().x());
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
- shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ GetShelf()->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
ASSERT_NE(-1, display.id());
- EXPECT_EQ(shelf->GetIdealBounds().width(),
+ EXPECT_EQ(layout_manager->GetIdealBounds().width(),
display.GetWorkAreaInsets().right());
EXPECT_GE(shelf_bounds.width(),
GetShelfWidget()->GetContentsView()->GetPreferredSize().width());
@@ -1713,7 +1725,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) {
status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen());
EXPECT_GE(status_bounds.width(),
status_area_widget->GetContentsView()->GetPreferredSize().width());
- EXPECT_EQ(shelf->GetIdealBounds().width(),
+ EXPECT_EQ(layout_manager->GetIdealBounds().width(),
display.GetWorkAreaInsets().right());
EXPECT_EQ(0, display.GetWorkAreaInsets().top());
EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
@@ -1721,7 +1733,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) {
EXPECT_EQ(display.work_area().right(), shelf_bounds.x());
EXPECT_EQ(display.bounds().y(), shelf_bounds.y());
EXPECT_EQ(display.bounds().height(), shelf_bounds.height());
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
EXPECT_EQ(ShelfLayoutManager::kAutoHideSize,
display.GetWorkAreaInsets().right());
@@ -1730,8 +1742,8 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) {
}
TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) {
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 200, 200);
@@ -1743,37 +1755,37 @@ TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) {
ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
aura::Window* window = widget->GetNativeWindow();
- shelf->LayoutShelf();
+ layout_manager->LayoutShelf();
gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen();
gfx::Rect bounds_shelf = window->bounds();
// Edge swipe when SHELF_VISIBLE should not change visibility state.
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
generator.GestureEdgeSwipe();
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
// Edge swipe when AUTO_HIDE_HIDDEN should change to AUTO_HIDE_SHOWN.
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- shelf->LayoutShelf();
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ layout_manager->LayoutShelf();
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
generator.GestureEdgeSwipe();
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
widget->SetFullscreen(true);
wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false);
- shelf->UpdateVisibilityState();
+ layout_manager->UpdateVisibilityState();
// Edge swipe in fullscreen + AUTO_HIDE_HIDDEN should show the shelf and
// remain fullscreen.
EXPECT_TRUE(widget->IsFullscreen());
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
generator.GestureEdgeSwipe();
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
EXPECT_TRUE(widget->IsFullscreen());
}
@@ -1809,8 +1821,10 @@ TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipeMultiMonitor) {
window_2->Show();
// Make sure both are set to auto-hide and both are hidden.
- shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ Shelf::ForWindow(window_1)->SetAutoHideBehavior(
+ SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ Shelf::ForWindow(window_2)->SetAutoHideBehavior(
+ SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
shelf_1->LayoutShelf();
shelf_2->LayoutShelf();
EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->visibility_state());
@@ -1856,7 +1870,6 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_GestureDrag) {
// these tests. Ignore it.
ui::GestureConfiguration::GetInstance()
->set_max_touch_move_in_pixels_for_click(0);
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
{
SCOPED_TRACE("BOTTOM");
RunGestureDragTests(gfx::Vector2d(0, 120));
@@ -1864,13 +1877,13 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_GestureDrag) {
{
SCOPED_TRACE("LEFT");
- shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
+ GetShelf()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
RunGestureDragTests(gfx::Vector2d(-120, 0));
}
{
SCOPED_TRACE("RIGHT");
- shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
+ GetShelf()->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
RunGestureDragTests(gfx::Vector2d(120, 0));
}
}
@@ -1880,52 +1893,52 @@ TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) {
return;
UpdateDisplay("800x600,800x600");
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->LayoutShelf();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ layout_manager->LayoutShelf();
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
// Create a visible window so auto-hide behavior is enforced
views::Widget* dummy = CreateTestWidget();
// Window visible => auto hide behaves normally.
- shelf->UpdateVisibilityState();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ layout_manager->UpdateVisibilityState();
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// Window minimized => auto hide disabled.
dummy->Minimize();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
// Window closed => auto hide disabled.
dummy->CloseNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
// Multiple window test
views::Widget* window1 = CreateTestWidget();
views::Widget* window2 = CreateTestWidget();
// both visible => normal autohide
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// either minimzed => normal autohide
window2->Minimize();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
window2->Restore();
window1->Minimize();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// both minimized => disable auto hide
window2->Minimize();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
// Test moving windows to/from other display.
window2->Restore();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// Move to second display.
window2->SetBounds(gfx::Rect(850, 50, 50, 50));
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
// Move back to primary display.
window2->SetBounds(gfx::Rect(50, 50, 50, 50));
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
}
// Test that the shelf animates back to its normal position upon a user
@@ -1936,10 +1949,10 @@ TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) {
// Test the shelf animates back to its original visible bounds when it is
// dragged when there are no visible windows.
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
gfx::Rect visible_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
{
// Enable animations so that we can make sure that they occur.
@@ -1953,8 +1966,8 @@ TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) {
gfx::Point end(start.x(), shelf_bounds_in_screen.bottom());
generator.GestureScrollSequence(start, end,
base::TimeDelta::FromMilliseconds(10), 5);
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
ShelfAnimationWaiter waiter(visible_bounds);
// Wait till the animation completes and check that it occurred.
@@ -1966,8 +1979,8 @@ TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) {
CreateTestWidget();
// Get the bounds of the shelf when it is hidden.
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
gfx::Rect auto_hidden_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
{
@@ -1984,18 +1997,18 @@ TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) {
// the auto hidden shelf.
generator.GestureScrollSequence(start, end,
base::TimeDelta::FromMilliseconds(10), 1);
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
ShelfAnimationWaiter waiter1(visible_bounds);
waiter1.WaitTillDoneAnimating();
EXPECT_TRUE(waiter1.WasValidAnimation());
// Test that the shelf animates to the auto hidden bounds after a swipe up
// on the visible shelf.
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state());
generator.GestureScrollSequence(start, end,
base::TimeDelta::FromMilliseconds(10), 1);
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
ShelfAnimationWaiter waiter2(auto_hidden_bounds);
waiter2.WaitTillDoneAnimating();
EXPECT_TRUE(waiter2.WasValidAnimation());
@@ -2003,29 +2016,29 @@ TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) {
}
TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) {
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
// Create a visible window so auto-hide behavior is enforced.
CreateTestWidget();
// Turn on auto-hide for the shelf.
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state());
// Show the status menu. That should make the shelf visible again.
Shell::GetInstance()->accelerator_controller()->PerformActionIfEnabled(
SHOW_SYSTEM_TRAY_BUBBLE);
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state());
EXPECT_TRUE(GetSystemTray()->HasSystemBubble());
}
TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) {
// Make sure the shelf is always visible.
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
- shelf->LayoutShelf();
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ layout_manager->LayoutShelf();
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 200, 200);
@@ -2044,7 +2057,7 @@ TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) {
widget_one->GetNativeWindow()->bounds().size().GetArea();
// Now hide the shelf.
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
// Both windows should be resized according to the shelf status.
EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(),
@@ -2054,7 +2067,7 @@ TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) {
widget_one->GetNativeWindow()->bounds().size().GetArea());
// Now show the shelf.
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
// Again both windows should be of the same size.
EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(),
@@ -2066,37 +2079,37 @@ TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) {
// Confirm that the shelf is dimmed only when content is maximized and
// shelf is not autohidden.
TEST_F(ShelfLayoutManagerTest, Dimming) {
- GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
std::unique_ptr<aura::Window> w1(CreateTestWindow());
w1->Show();
wm::ActivateWindow(w1.get());
// Normal window doesn't dim shelf.
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
- ShelfWidget* shelf = GetShelfWidget();
- EXPECT_FALSE(shelf->GetDimsShelf());
+ ShelfWidget* shelf_widget = GetShelfWidget();
+ EXPECT_FALSE(shelf_widget->GetDimsShelf());
// Maximized window does.
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_TRUE(shelf->GetDimsShelf());
+ EXPECT_TRUE(shelf_widget->GetDimsShelf());
// Change back to normal stops dimming.
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
- EXPECT_FALSE(shelf->GetDimsShelf());
+ EXPECT_FALSE(shelf_widget->GetDimsShelf());
// Changing back to maximized dims again.
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_TRUE(shelf->GetDimsShelf());
+ EXPECT_TRUE(shelf_widget->GetDimsShelf());
// Changing shelf to autohide stops dimming.
- GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- EXPECT_FALSE(shelf->GetDimsShelf());
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ EXPECT_FALSE(shelf_widget->GetDimsShelf());
}
// Make sure that the shelf will not hide if the mouse is between a bubble and
// the shelf.
TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) {
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
+ ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController()
->shelf_widget()
->status_area_widget();
@@ -2105,7 +2118,7 @@ TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) {
// Create a visible window so auto-hide behavior is enforced.
CreateTestWidget();
- shelf->LayoutShelf();
+ layout_manager->LayoutShelf();
ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
// Make two iterations - first without a message bubble which should make
@@ -2114,13 +2127,13 @@ TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) {
for (int i = 0; i < 2; i++) {
// Make sure the shelf is visible and position the mouse over it. Then
// allow auto hide.
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
gfx::Point center =
status_area_widget->GetWindowBoundsInScreen().CenterPoint();
generator.MoveMouseTo(center.x(), center.y());
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- EXPECT_TRUE(shelf->IsVisible());
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ EXPECT_TRUE(layout_manager->IsVisible());
if (!i) {
// In our first iteration we make sure there is no bubble.
tray->CloseSystemBubble();
@@ -2135,12 +2148,12 @@ TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) {
// Move the pointer over the edge of the shelf.
generator.MoveMouseTo(
center.x(), status_area_widget->GetWindowBoundsInScreen().y() - 8);
- shelf->UpdateVisibilityState();
+ layout_manager->UpdateVisibilityState();
if (i) {
- EXPECT_TRUE(shelf->IsVisible());
+ EXPECT_TRUE(layout_manager->IsVisible());
EXPECT_TRUE(status_area_widget->IsMessageBubbleShown());
} else {
- EXPECT_FALSE(shelf->IsVisible());
+ EXPECT_FALSE(layout_manager->IsVisible());
EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
}
}
@@ -2190,7 +2203,7 @@ TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) {
EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT,
GetShelfWidget()->GetBackgroundType());
- GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
std::unique_ptr<aura::Window> w1(CreateTestWindow());
w1->Show();
wm::ActivateWindow(w1.get());
@@ -2210,7 +2223,6 @@ TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) {
// Verify the hit bounds of the status area extend to the edge of the shelf.
TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) {
UpdateDisplay("400x400");
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController()
->shelf_widget()
->status_area_widget();
@@ -2225,6 +2237,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) {
EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
// Test bottom right pixel for right alignment.
+ Shelf* shelf = GetShelf();
msw 2016/06/01 00:53:24 nit: it seems random when you choose to cache GetS
James Cook 2016/06/01 15:53:06 Updated to cache GetShelf() everywhere, unless it
shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
generator.ClickLeftButton();
@@ -2246,18 +2259,18 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) {
// target bounds are updated to reflect the new state.
TEST_F(ShelfLayoutManagerTest,
ShelfAutoHideToggleDuringAnimationUpdatesBounds) {
- ShelfLayoutManager* shelf_manager = GetShelfLayoutManager();
+ Shelf* shelf = GetShelf();
aura::Window* status_window = GetShelfWidget()->status_area_widget()->
GetNativeView();
gfx::Rect initial_bounds = status_window->bounds();
ui::ScopedAnimationDurationScaleMode regular_animations(
ui::ScopedAnimationDurationScaleMode::SLOW_DURATION);
- shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
gfx::Rect hide_target_bounds = status_window->GetTargetBounds();
EXPECT_GT(hide_target_bounds.y(), initial_bounds.y());
- shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
gfx::Rect reshow_target_bounds = status_window->GetTargetBounds();
EXPECT_EQ(initial_bounds, reshow_target_bounds);
}
@@ -2265,9 +2278,7 @@ TEST_F(ShelfLayoutManagerTest,
// Tests that during shutdown, that window activation changes are properly
// handled, and do not crash (crbug.com/458768)
TEST_F(ShelfLayoutManagerTest, ShutdownHandlesWindowActivation) {
- ShelfLayoutManager* shelf_manager = GetShelfLayoutManager();
- ShelfWidget* shelf = GetShelfWidget();
- shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
aura::Window* window1 = CreateTestWindowInShellWithId(0);
window1->SetBounds(gfx::Rect(0, 0, 100, 100));
@@ -2278,7 +2289,7 @@ TEST_F(ShelfLayoutManagerTest, ShutdownHandlesWindowActivation) {
window2->Show();
wm::ActivateWindow(window1);
- shelf->Shutdown();
+ GetShelfWidget()->Shutdown();
// Deleting a focused maximized window will switch focus to |window2|. This
// would normally cause the ShelfLayoutManager to update its state. However

Powered by Google App Engine
This is Rietveld 408576698