Chromium Code Reviews| 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 30854ef63ce71621958434331a548129fe2c0d0b..a61d6fe794ad287bb508e227871572be11a535e1 100644 |
| --- a/ash/shelf/shelf_layout_manager_unittest.cc |
| +++ b/ash/shelf/shelf_layout_manager_unittest.cc |
| @@ -19,7 +19,6 @@ |
| #include "ash/common/wm/window_state.h" |
| #include "ash/common/wm_shell.h" |
| #include "ash/display/display_manager.h" |
| -#include "ash/display/window_tree_host_manager.h" |
| #include "ash/root_window_controller.h" |
| #include "ash/shelf/shelf.h" |
| #include "ash/shelf/shelf_layout_manager_observer.h" |
| @@ -69,11 +68,7 @@ ShelfWidget* GetShelfWidget() { |
| } |
| ShelfLayoutManager* GetShelfLayoutManager() { |
| - return Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| -} |
| - |
| -SystemTray* GetSystemTray() { |
| - return Shell::GetPrimaryRootWindowController()->GetSystemTray(); |
| + return GetShelfWidget()->shelf_layout_manager(); |
| } |
| // Class which waits till the shelf finishes animating to the target size and |
| @@ -302,8 +297,7 @@ class ShelfLayoutManagerTest : public test::AshTestBase { |
| return out; |
| } |
| - // Create a simple widget attached to the current context (will |
| - // delete on TearDown). |
| + // Create a simple widget in the current context (will delete on TearDown). |
| views::Widget* CreateTestWidget() { |
| views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| params.bounds = gfx::Rect(0, 0, 200, 200); |
| @@ -334,12 +328,8 @@ class ShelfLayoutManagerTest : public test::AshTestBase { |
| void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { |
| 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); |
| - params.bounds = gfx::Rect(0, 0, 200, 200); |
| - params.context = CurrentContext(); |
| - widget->Init(params); |
| - widget->Show(); |
| + |
| + views::Widget* widget = CreateTestWidget(); |
| widget->Maximize(); |
| // The time delta should be large enough to prevent accidental fling creation. |
| @@ -363,7 +353,7 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { |
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| layout_manager->LayoutShelf(); |
| - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| + ui::test::EventGenerator& generator(GetEventGenerator()); |
| const int kNumScrollSteps = 4; |
| ShelfDragCallback handler(shelf_hidden, shelf_shown); |
| @@ -626,9 +616,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { |
| 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 = |
| - screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| + display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| ASSERT_NE(-1, display.id()); |
| // Bottom inset should be the max of widget heights. |
| EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
| @@ -639,15 +627,14 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { |
| StepWidgetLayerAnimatorToEnd(shelf_widget); |
| StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
| EXPECT_EQ(SHELF_HIDDEN, manager->visibility_state()); |
| - display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| - |
| + display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| // Make sure the bounds of the two widgets changed. |
| EXPECT_GE(shelf_widget->GetNativeView()->bounds().y(), |
| - screen->GetPrimaryDisplay().bounds().bottom()); |
| + display.bounds().bottom()); |
| EXPECT_GE(shelf_widget->status_area_widget()->GetNativeView()->bounds().y(), |
| - screen->GetPrimaryDisplay().bounds().bottom()); |
| + display.bounds().bottom()); |
| // And show it again. |
| SetState(manager, SHELF_VISIBLE); |
| @@ -655,14 +642,14 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { |
| StepWidgetLayerAnimatorToEnd(shelf_widget); |
| StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
| EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
| - display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| + display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
| // Make sure the bounds of the two widgets changed. |
| shelf_bounds = shelf_widget->GetNativeView()->bounds(); |
| - EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); |
| + EXPECT_LT(shelf_bounds.y(), display.bounds().bottom()); |
| status_bounds = shelf_widget->status_area_widget()->GetNativeView()->bounds(); |
| - EXPECT_LT(status_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); |
| + EXPECT_LT(status_bounds.y(), display.bounds().bottom()); |
| } |
| // Makes sure LayoutShelf invoked while animating cleans things up. |
| @@ -677,19 +664,15 @@ TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { |
| SetState(layout_manager, SHELF_HIDDEN); |
| layout_manager->LayoutShelf(); |
| EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
| - display::Display display = |
| - display::Screen::GetScreen()->GetDisplayNearestWindow( |
| - Shell::GetPrimaryRootWindow()); |
| + display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| // Make sure the bounds of the two widgets changed. |
| ShelfWidget* shelf_widget = GetShelfWidget(); |
| - EXPECT_GE( |
| - shelf_widget->GetNativeView()->bounds().y(), |
| - display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom()); |
| - EXPECT_GE( |
| - shelf_widget->status_area_widget()->GetNativeView()->bounds().y(), |
| - display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom()); |
| + EXPECT_GE(shelf_widget->GetNativeView()->bounds().y(), |
| + display.bounds().bottom()); |
| + EXPECT_GE(shelf_widget->status_area_widget()->GetNativeView()->bounds().y(), |
| + display.bounds().bottom()); |
| } |
| // Test that switching to a different visibility state does not restart the |
| @@ -732,81 +715,60 @@ TEST_F(ShelfLayoutManagerTest, ShelfUpdatedWhenStatusAreaChangesSize) { |
| test::ShelfTestAPI(shelf).shelf_view()->width()); |
| } |
| -#if defined(OS_WIN) |
| -// RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| -#define MAYBE_AutoHide DISABLED_AutoHide |
| -#else |
| -#define MAYBE_AutoHide AutoHide |
| -#endif |
| - |
| // Various assertions around auto-hide. |
| -TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) { |
| - aura::Window* root = Shell::GetPrimaryRootWindow(); |
| - ui::test::EventGenerator generator(root, root); |
| - generator.MoveMouseTo(0, 0); |
| +TEST_F(ShelfLayoutManagerTest, AutoHide) { |
| + ui::test::EventGenerator& generator(GetEventGenerator()); |
| Shelf* shelf = GetShelf(); |
| ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| shelf->SetAutoHideBehavior(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); |
| - params.context = CurrentContext(); |
| - // Widget is now owned by the parent window. |
| - widget->Init(params); |
| + views::Widget* widget = CreateTestWidget(); |
| widget->Maximize(); |
| - widget->Show(); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| // LayoutShelf() forces the animation to completion, at which point the |
| // shelf should go off the screen. |
| layout_manager->LayoutShelf(); |
| - int shelf_insets = GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); |
| + const int shelf_insets = GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); |
| - EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize, |
| + display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| + const int display_bottom = display.bounds().bottom(); |
| + EXPECT_EQ(display_bottom - kShelfAutoHideSize, |
| GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| - EXPECT_EQ(root->bounds().bottom() - shelf_insets, |
| - display::Screen::GetScreen() |
| - ->GetDisplayNearestWindow(root) |
| - .work_area() |
| - .bottom()); |
| + EXPECT_EQ(display_bottom - shelf_insets, display.work_area().bottom()); |
| // Move the mouse to the bottom of the screen. |
| - generator.MoveMouseTo(0, root->bounds().bottom() - 1); |
| + generator.MoveMouseTo(0, display_bottom - 1); |
| // Shelf should be shown again (but it shouldn't have changed the work area). |
| SetState(layout_manager, SHELF_AUTO_HIDE); |
| EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| layout_manager->LayoutShelf(); |
| - EXPECT_EQ(root->bounds().bottom() - layout_manager->GetIdealBounds().height(), |
| + EXPECT_EQ(display_bottom - layout_manager->GetIdealBounds().height(), |
| GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| - EXPECT_EQ(root->bounds().bottom() - shelf_insets, |
| - display::Screen::GetScreen() |
| - ->GetDisplayNearestWindow(root) |
| - .work_area() |
| - .bottom()); |
| + EXPECT_EQ(display_bottom - shelf_insets, display.work_area().bottom()); |
| // Move mouse back up. |
| generator.MoveMouseTo(0, 0); |
| SetState(layout_manager, SHELF_AUTO_HIDE); |
| EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| layout_manager->LayoutShelf(); |
| - EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize, |
| + EXPECT_EQ(display_bottom - kShelfAutoHideSize, |
| GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| // Drag mouse to bottom of screen. |
| generator.PressLeftButton(); |
| - generator.MoveMouseTo(0, root->bounds().bottom() - 1); |
| + generator.MoveMouseTo(0, display_bottom - 1); |
| UpdateAutoHideStateNow(); |
| EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| generator.ReleaseLeftButton(); |
| - generator.MoveMouseTo(1, root->bounds().bottom() - 1); |
| + generator.MoveMouseTo(1, display_bottom - 1); |
| UpdateAutoHideStateNow(); |
| EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| generator.PressLeftButton(); |
| - generator.MoveMouseTo(1, root->bounds().bottom() - 1); |
| + generator.MoveMouseTo(1, display_bottom - 1); |
| UpdateAutoHideStateNow(); |
| EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| } |
| @@ -828,15 +790,12 @@ TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) { |
| // visible. |
| CreateTestWidget(); |
| - aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| - ASSERT_EQ(root_windows[0], |
| - GetShelfWidget()->GetNativeWindow()->GetRootWindow()); |
| - |
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| - int right_edge = root_windows[0]->GetBoundsInScreen().right() - 1; |
| - int y = root_windows[0]->GetBoundsInScreen().y(); |
| + display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| + const int right_edge = display.bounds().right() - 1; |
| + const int y = display.bounds().y(); |
| // Start off the mouse nowhere near the shelf; the shelf should be hidden. |
| ui::test::EventGenerator& generator(GetEventGenerator()); |
| @@ -907,48 +866,24 @@ TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) { |
| // Assertions around the lock screen showing. |
| TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { |
| - if (!SupportsHostWindowResize()) |
| - return; |
| - |
| - // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| - // it isn't over the shelf. |
| - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| - gfx::Point()); |
| - generator.MoveMouseTo(0, 0); |
| - |
| Shelf* shelf = GetShelf(); |
| ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| shelf->SetAutoHideBehavior(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); |
| - params.context = CurrentContext(); |
| - // Widget is now owned by the parent window. |
| - widget->Init(params); |
| + views::Widget* widget = CreateTestWidget(); |
| widget->Maximize(); |
| - widget->Show(); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| - aura::Window* root = Shell::GetPrimaryRootWindow(); |
| // LayoutShelf() forces the animation to completion, at which point the |
| // shelf should go off the screen. |
| layout_manager->LayoutShelf(); |
| - EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize, |
| + display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| + EXPECT_EQ(display.bounds().bottom() - kShelfAutoHideSize, |
| GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| - aura::Window* lock_container = Shell::GetContainer( |
| - Shell::GetPrimaryRootWindow(), kShellWindowId_LockScreenContainer); |
| - |
| - views::Widget* lock_widget = new views::Widget; |
| - views::Widget::InitParams lock_params(views::Widget::InitParams::TYPE_WINDOW); |
| - lock_params.bounds = gfx::Rect(0, 0, 200, 200); |
| - params.context = CurrentContext(); |
| - lock_params.parent = lock_container; |
| - // Widget is now owned by the parent window. |
| - lock_widget->Init(lock_params); |
| + std::unique_ptr<views::Widget> lock_widget(AshTestBase::CreateTestWidget( |
| + nullptr, kShellWindowId_LockScreenContainer, gfx::Rect(200, 200))); |
| lock_widget->Maximize(); |
| - lock_widget->Show(); |
| // Lock the screen. |
| LockScreen(); |
| @@ -961,21 +896,8 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { |
| // Assertions around SetAutoHideBehavior. |
| TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { |
| - // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| - // it isn't over the shelf. |
| - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| - gfx::Point()); |
| - generator.MoveMouseTo(0, 0); |
| - |
| Shelf* shelf = GetShelf(); |
| - views::Widget* widget = new views::Widget; |
| - views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| - params.bounds = gfx::Rect(0, 0, 200, 200); |
| - params.context = CurrentContext(); |
| - // Widget is now owned by the parent window. |
| - widget->Init(params); |
| - widget->Show(); |
| - aura::Window* window = widget->GetNativeWindow(); |
| + views::Widget* widget = CreateTestWidget(); |
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| @@ -985,18 +907,13 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { |
| widget->Maximize(); |
| EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| - EXPECT_EQ(display::Screen::GetScreen() |
| - ->GetDisplayNearestWindow(window) |
| - .work_area() |
| - .bottom(), |
| + display::Screen* screen = display::Screen::GetScreen(); |
| + EXPECT_EQ(screen->GetPrimaryDisplay().work_area().bottom(), |
| widget->GetWorkAreaBoundsInScreen().bottom()); |
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| - EXPECT_EQ(display::Screen::GetScreen() |
| - ->GetDisplayNearestWindow(window) |
| - .work_area() |
| - .bottom(), |
| + EXPECT_EQ(screen->GetPrimaryDisplay().work_area().bottom(), |
| widget->GetWorkAreaBoundsInScreen().bottom()); |
| ui::ScopedAnimationDurationScaleMode animation_duration( |
| @@ -1008,37 +925,20 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { |
| StepWidgetLayerAnimatorToEnd(shelf_widget); |
| StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
| EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| - EXPECT_EQ(display::Screen::GetScreen() |
| - ->GetDisplayNearestWindow(window) |
| - .work_area() |
| - .bottom(), |
| + EXPECT_EQ(screen->GetPrimaryDisplay().work_area().bottom(), |
| widget->GetWorkAreaBoundsInScreen().bottom()); |
| } |
| // Basic assertions around the dimming of the shelf. |
| TEST_F(ShelfLayoutManagerTest, DimmingBehavior) { |
| - // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| - // it isn't over the shelf. |
| - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| - gfx::Point()); |
| - generator.MoveMouseTo(0, 0); |
| + ui::test::EventGenerator& generator(GetEventGenerator()); |
| ShelfWidget* shelf_widget = GetShelfWidget(); |
| shelf_widget->DisableDimmingAnimationsForTest(); |
| - |
| - views::Widget* widget = new views::Widget; |
| - views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| - params.bounds = gfx::Rect(0, 0, 200, 200); |
| - params.context = CurrentContext(); |
| - // Widget is now owned by the parent window. |
| - widget->Init(params); |
| - widget->Show(); |
| - aura::Window* window = widget->GetNativeWindow(); |
| - gfx::Rect display_bounds( |
| - display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
| - |
| - gfx::Point off_shelf = display_bounds.CenterPoint(); |
| + display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| + gfx::Point off_shelf = display.bounds().CenterPoint(); |
| gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); |
| + views::Widget* widget = CreateTestWidget(); |
| // Test there is no dimming object active at this point. |
| generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); |
| @@ -1094,14 +994,8 @@ TEST_F(ShelfLayoutManagerTest, DimmingBehaviorDualDisplay) { |
| return; |
| // Create two displays. |
| - Shell* shell = Shell::GetInstance(); |
| UpdateDisplay("0+0-200x200,+200+0-100x100"); |
| - EXPECT_EQ(2U, shell->display_manager()->GetNumDisplays()); |
| - |
| - WindowTreeHostManager* window_tree_host_manager = |
| - shell->window_tree_host_manager(); |
| - aura::Window::Windows root_windows = |
| - window_tree_host_manager->GetAllRootWindows(); |
| + aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| EXPECT_EQ(root_windows.size(), 2U); |
| std::vector<ShelfWidget*> shelf_widgets; |
| @@ -1115,13 +1009,11 @@ TEST_F(ShelfLayoutManagerTest, DimmingBehaviorDualDisplay) { |
| shelf_widgets.back()->DisableDimmingAnimationsForTest(); |
| // Create a maximized window to create the dimmer. |
| - views::Widget* widget = new views::Widget; |
| - views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| + views::Widget::InitParams params; |
| params.context = root_window; |
| params.bounds = root_window->GetBoundsInScreen(); |
| params.show_state = ui::SHOW_STATE_MAXIMIZED; |
| - widget->Init(params); |
| - widget->Show(); |
| + CreateTestWidgetWithParams(params); |
| } |
| ui::test::EventGenerator& generator(GetEventGenerator()); |
| @@ -1147,30 +1039,18 @@ TEST_F(ShelfLayoutManagerTest, DimmingBehaviorDualDisplay) { |
| // Assertions around the dimming of the shelf in conjunction with menus. |
| TEST_F(ShelfLayoutManagerTest, DimmingBehaviorWithMenus) { |
| - // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| - // it isn't over the shelf. |
| - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| - gfx::Point()); |
| + ui::test::EventGenerator& generator(GetEventGenerator()); |
| generator.MoveMouseTo(0, 0); |
| ShelfWidget* shelf_widget = GetShelfWidget(); |
| shelf_widget->DisableDimmingAnimationsForTest(); |
| - views::Widget* widget = new views::Widget; |
| - views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| - params.bounds = gfx::Rect(0, 0, 200, 200); |
| - params.context = CurrentContext(); |
| - // Widget is now owned by the parent window. |
| - widget->Init(params); |
| - widget->Show(); |
| - aura::Window* window = widget->GetNativeWindow(); |
| - gfx::Rect display_bounds( |
| - display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
| - |
| // After maximization, the shelf should be visible and the dimmer created. |
| + views::Widget* widget = CreateTestWidget(); |
| widget->Maximize(); |
| - gfx::Point off_shelf = display_bounds.CenterPoint(); |
| + display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| + gfx::Point off_shelf = display.bounds().CenterPoint(); |
| gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); |
| // Moving the mouse on the shelf should undim the bar. |
| @@ -1216,20 +1096,8 @@ TEST_F(ShelfLayoutManagerTest, DimmingBehaviorWithMenus) { |
| // Verifies the shelf is visible when status/shelf is focused. |
| TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { |
| - // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| - // it isn't over the shelf. |
| - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| - gfx::Point()); |
| - generator.MoveMouseTo(0, 0); |
| - |
| Shelf* shelf = GetShelf(); |
| - views::Widget* widget = new views::Widget; |
| - views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| - params.bounds = gfx::Rect(0, 0, 200, 200); |
| - params.context = CurrentContext(); |
| - // Widget is now owned by the parent window. |
| - widget->Init(params); |
| - widget->Show(); |
| + views::Widget* widget = CreateTestWidget(); |
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| @@ -1322,16 +1190,8 @@ TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { |
| return; |
| // Create two displays. |
| - Shell* shell = Shell::GetInstance(); |
| - DisplayManager* display_manager = shell->display_manager(); |
| - EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
| UpdateDisplay("0+0-200x200,+200+0-100x100"); |
| - EXPECT_EQ(2U, display_manager->GetNumDisplays()); |
| - |
| - WindowTreeHostManager* window_tree_host_manager = |
| - shell->window_tree_host_manager(); |
| - aura::Window::Windows root_windows = |
| - window_tree_host_manager->GetAllRootWindows(); |
| + aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| EXPECT_EQ(root_windows.size(), 2U); |
| // Get the shelves in both displays and set them to be 'AutoHide'. |
| @@ -1363,7 +1223,7 @@ TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { |
| // Activate one window in one display and manually trigger the update of shelf |
| // visibility. |
| wm::ActivateWindow(window_1); |
| - shell->UpdateShelfVisibility(); |
| + Shell::GetInstance()->UpdateShelfVisibility(); |
| EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); |
| @@ -1373,7 +1233,7 @@ TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { |
| // Show app list. |
| WmShell::Get()->ShowAppList(); |
| - shell->UpdateShelfVisibility(); |
| + Shell::GetInstance()->UpdateShelfVisibility(); |
| // Only the shelf in the active display should be shown, the other is hidden. |
| EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
| @@ -1425,7 +1285,6 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { |
| // 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(); |
| Shelf* shelf = GetShelf(); |
| ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| layout_manager->LayoutShelf(); |
| @@ -1442,7 +1301,7 @@ TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowSingleDisplay) { |
| wm_shell->SimulateModalWindowOpenForTesting(true); |
| EXPECT_TRUE(wm_shell->IsSystemModalWindowOpen()); |
| EXPECT_FALSE(wm::CanActivateWindow(window)); |
| - shell->UpdateShelfVisibility(); |
| + Shell::GetInstance()->UpdateShelfVisibility(); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| } |
| @@ -1454,15 +1313,8 @@ TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { |
| return; |
| // Create two displays. |
| - Shell* shell = Shell::GetInstance(); |
| - DisplayManager* display_manager = shell->display_manager(); |
| UpdateDisplay("200x200,100x100"); |
| - EXPECT_EQ(2U, display_manager->GetNumDisplays()); |
| - |
| - WindowTreeHostManager* window_tree_host_manager = |
| - shell->window_tree_host_manager(); |
| - aura::Window::Windows root_windows = |
| - window_tree_host_manager->GetAllRootWindows(); |
| + aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| EXPECT_EQ(2U, root_windows.size()); |
| // Get the shelves in both displays and set them to be 'AutoHide'. |
| @@ -1499,7 +1351,7 @@ TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { |
| EXPECT_TRUE(wm_shell->IsSystemModalWindowOpen()); |
| EXPECT_FALSE(wm::CanActivateWindow(window_1)); |
| EXPECT_FALSE(wm::CanActivateWindow(window_2)); |
| - shell->UpdateShelfVisibility(); |
| + Shell::GetInstance()->UpdateShelfVisibility(); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); |
| EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); |
| @@ -1538,7 +1390,6 @@ TEST_F(ShelfLayoutManagerTest, FullscreenWindowOnSecondDisplay) { |
| return; |
| UpdateDisplay("800x600,800x600"); |
| - DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| Shell::RootWindowControllerList root_window_controllers = |
| Shell::GetAllRootWindowControllers(); |
| @@ -1546,13 +1397,13 @@ TEST_F(ShelfLayoutManagerTest, FullscreenWindowOnSecondDisplay) { |
| // Create windows on either display. |
| aura::Window* window1 = CreateTestWindow(); |
| window1->SetBoundsInScreen(gfx::Rect(0, 0, 100, 100), |
| - display_manager->GetDisplayAt(0)); |
| + display::Screen::GetScreen()->GetAllDisplays()[0]); |
| window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| window1->Show(); |
| aura::Window* window2 = CreateTestWindow(); |
| window2->SetBoundsInScreen(gfx::Rect(800, 0, 100, 100), |
| - display_manager->GetDisplayAt(1)); |
| + display::Screen::GetScreen()->GetAllDisplays()[1]); |
| window2->Show(); |
| EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
| @@ -1584,15 +1435,8 @@ TEST_F(ShelfLayoutManagerTest, PinnedWindowHidesShelf) { |
| EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| } |
| -#if defined(OS_WIN) |
| -// RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| -#define MAYBE_SetAlignment DISABLED_SetAlignment |
| -#else |
| -#define MAYBE_SetAlignment SetAlignment |
| -#endif |
| - |
| // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). |
| -TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { |
| +TEST_F(ShelfLayoutManagerTest, SetAlignment) { |
| Shelf* shelf = GetShelf(); |
| ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| // Force an initial layout. |
| @@ -1602,15 +1446,13 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { |
| shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| gfx::Rect shelf_bounds(GetShelfWidget()->GetWindowBoundsInScreen()); |
| - const display::Screen* screen = display::Screen::GetScreen(); |
| - display::Display display = |
| - screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| + display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| ASSERT_NE(-1, display.id()); |
| EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
| display.GetWorkAreaInsets().left()); |
| EXPECT_GE(shelf_bounds.width(), |
| GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); |
| - EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); |
| + EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetPrimarySystemTray()->shelf_alignment()); |
| StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
| gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| EXPECT_GE(status_bounds.width(), |
| @@ -1624,7 +1466,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { |
| EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); |
| EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); |
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| - display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| + display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
| display.GetWorkAreaInsets().left()); |
| EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
| @@ -1632,15 +1474,14 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { |
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| - display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
| - display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| + display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| ASSERT_NE(-1, display.id()); |
| EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
| display.GetWorkAreaInsets().right()); |
| EXPECT_GE(shelf_bounds.width(), |
| GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); |
| - EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment()); |
| + EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetPrimarySystemTray()->shelf_alignment()); |
| status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); |
| EXPECT_GE(status_bounds.width(), |
| status_area_widget->GetContentsView()->GetPreferredSize().width()); |
| @@ -1653,7 +1494,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { |
| EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); |
| EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); |
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| - display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| + display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
| display.GetWorkAreaInsets().right()); |
| EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
| @@ -1664,15 +1505,10 @@ TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) { |
| Shelf* shelf = GetShelf(); |
| ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| shelf->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); |
| - params.context = CurrentContext(); |
| - widget->Init(params); |
| - widget->Show(); |
| + views::Widget* widget = CreateTestWidget(); |
| widget->Maximize(); |
| - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| + ui::test::EventGenerator& generator(GetEventGenerator()); |
| aura::Window* window = widget->GetNativeWindow(); |
| layout_manager->LayoutShelf(); |
| @@ -1713,11 +1549,7 @@ TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipeMultiMonitor) { |
| return; |
| // Create two displays. |
| - Shell* shell = Shell::GetInstance(); |
| - DisplayManager* display_manager = shell->display_manager(); |
| UpdateDisplay("200x200,100x100"); |
| - ASSERT_EQ(2U, display_manager->GetNumDisplays()); |
| - |
| auto root_window_controllers = Shell::GetAllRootWindowControllers(); |
| ASSERT_EQ(2U, root_window_controllers.size()); |
| Shelf* shelf_1 = root_window_controllers[0]->GetShelf(); |
| @@ -1758,7 +1590,7 @@ TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipeMultiMonitor) { |
| EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); |
| // Back to normal after an update. |
| - shell->UpdateShelfVisibility(); |
| + Shell::GetInstance()->UpdateShelfVisibility(); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); |
| EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); |
| @@ -1771,14 +1603,7 @@ TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipeMultiMonitor) { |
| EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_2->GetAutoHideState()); |
| } |
| -#if defined(OS_WIN) |
| -// RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| -#define MAYBE_GestureDrag DISABLED_GestureDrag |
| -#else |
| -#define MAYBE_GestureDrag GestureDrag |
| -#endif |
| - |
| -TEST_F(ShelfLayoutManagerTest, MAYBE_GestureDrag) { |
| +TEST_F(ShelfLayoutManagerTest, GestureDrag) { |
| // Slop is an implementation detail of gesture recognition, and complicates |
| // these tests. Ignore it. |
| ui::GestureConfiguration::GetInstance() |
| @@ -1860,9 +1685,6 @@ TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) { |
| // Test that the shelf animates back to its normal position upon a user |
| // completing a gesture drag. |
| TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) { |
| - if (!SupportsHostWindowResize()) |
| - return; |
| - |
| // Test the shelf animates back to its original visible bounds when it is |
| // dragged when there are no visible windows. |
| Shelf* shelf = GetShelf(); |
| @@ -1875,7 +1697,7 @@ TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) { |
| ui::ScopedAnimationDurationScaleMode regular_animations( |
| ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| + ui::test::EventGenerator& generator(GetEventGenerator()); |
| gfx::Rect shelf_bounds_in_screen = |
| GetShelfWidget()->GetWindowBoundsInScreen(); |
| gfx::Point start(shelf_bounds_in_screen.CenterPoint()); |
| @@ -1907,7 +1729,7 @@ TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) { |
| gfx::Point start = |
| GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); |
| gfx::Point end(start.x(), start.y() - 100); |
| - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| + ui::test::EventGenerator& generator(GetEventGenerator()); |
| // Test that the shelf animates to the visible bounds after a swipe up on |
| // the auto hidden shelf. |
| @@ -1947,7 +1769,7 @@ TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { |
| SHOW_SYSTEM_TRAY_BUBBLE); |
| EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| - EXPECT_TRUE(GetSystemTray()->HasSystemBubble()); |
| + EXPECT_TRUE(GetPrimarySystemTray()->HasSystemBubble()); |
| } |
| TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { |
| @@ -1957,13 +1779,10 @@ TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { |
| shelf->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); |
| - params.context = CurrentContext(); |
| - views::Widget* widget_one = CreateTestWidgetWithParams(params); |
| + views::Widget* widget_one = CreateTestWidget(); |
| widget_one->Maximize(); |
| - views::Widget* widget_two = CreateTestWidgetWithParams(params); |
| + views::Widget* widget_two = CreateTestWidget(); |
| widget_two->Maximize(); |
| widget_two->Activate(); |
| @@ -2031,13 +1850,13 @@ TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) { |
| ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| StatusAreaWidget* status_area_widget = |
| shelf->shelf_widget()->status_area_widget(); |
| - SystemTray* tray = GetSystemTray(); |
| + SystemTray* tray = GetPrimarySystemTray(); |
| // Create a visible window so auto-hide behavior is enforced. |
| CreateTestWidget(); |
| layout_manager->LayoutShelf(); |
| - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| + ui::test::EventGenerator& generator(GetEventGenerator()); |
| // Make two iterations - first without a message bubble which should make |
| // the shelf disappear and then with a message bubble which should keep it |
| @@ -2121,40 +1940,41 @@ TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) { |
| EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); |
| } |
| -#if defined(OS_CHROMEOS) |
| -#define MAYBE_StatusAreaHitBoxCoversEdge StatusAreaHitBoxCoversEdge |
| -#else |
| -#define MAYBE_StatusAreaHitBoxCoversEdge DISABLED_StatusAreaHitBoxCoversEdge |
| -#endif |
| - |
| // Verify the hit bounds of the status area extend to the edge of the shelf. |
| -TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) { |
| - UpdateDisplay("400x400"); |
| - Shelf* shelf = GetShelf(); |
| - StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController() |
| - ->shelf_widget() |
| - ->status_area_widget(); |
| - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| - generator.MoveMouseTo(399, 399); |
| +TEST_F(ShelfLayoutManagerTest, StatusAreaHitBoxCoversEdge) { |
| + StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
| + ui::test::EventGenerator& generator(GetEventGenerator()); |
| + display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| + gfx::Rect inset_display_bounds = display.bounds(); |
| + inset_display_bounds.Inset(0, 0, 1, 1); |
| // Test bottom right pixel for bottom alignment. |
| + GetShelf()->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| + generator.MoveMouseTo(inset_display_bounds.bottom_right()); |
| EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| generator.ClickLeftButton(); |
|
James Cook
2016/08/02 18:17:37
nit: put this inside the #if so Windows doesn't ge
msw
2016/08/02 18:23:44
Done.
|
| +#if !defined(OS_WIN) |
| + // The bottom right pixel doesn't work on Windows; see crbug.com/633434 |
| EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| +#endif |
| generator.ClickLeftButton(); |
| EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| // Test bottom right pixel for right alignment. |
| - shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| + GetShelf()->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| + generator.MoveMouseTo(inset_display_bounds.bottom_right()); |
| EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| generator.ClickLeftButton(); |
|
James Cook
2016/08/02 18:17:38
ditto
msw
2016/08/02 18:23:44
Done.
|
| +#if !defined(OS_WIN) |
| + // The bottom right pixel doesn't work on Windows; see crbug.com/633434 |
| EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| +#endif |
| generator.ClickLeftButton(); |
| EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| // Test bottom left pixel for left alignment. |
| - generator.MoveMouseTo(0, 399); |
| - shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| + generator.MoveMouseTo(inset_display_bounds.bottom_left()); |
| + GetShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| generator.ClickLeftButton(); |
| EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| @@ -2166,18 +1986,17 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) { |
| // target bounds are updated to reflect the new state. |
| TEST_F(ShelfLayoutManagerTest, |
| ShelfAutoHideToggleDuringAnimationUpdatesBounds) { |
| - 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->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| + GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); |
| EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); |
| - shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| + GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); |
| EXPECT_EQ(initial_bounds, reshow_target_bounds); |
| } |
| @@ -2185,8 +2004,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) { |
| - Shelf* shelf = GetShelf(); |
| - shelf->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)); |
| @@ -2208,13 +2026,11 @@ TEST_F(ShelfLayoutManagerTest, ShutdownHandlesWindowActivation) { |
| TEST_F(ShelfLayoutManagerTest, ShelfLayoutInUnifiedDesktop) { |
| if (!SupportsMultipleDisplays()) |
| return; |
| - Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); |
| + Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); |
| UpdateDisplay("500x400, 500x400"); |
| - StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController() |
| - ->shelf_widget() |
| - ->status_area_widget(); |
| + StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
| EXPECT_TRUE(status_area_widget->IsVisible()); |
| // Shelf should be in the first display's area. |
| gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |