| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/shelf/shelf_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shelf/shelf_constants.h" | 8 #include "ash/shelf/shelf_constants.h" |
| 9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
| 10 #include "ash/shelf/shelf_view.h" | 10 #include "ash/shelf/shelf_view.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 ShelfWidget* GetShelfWidget() { | 30 ShelfWidget* GetShelfWidget() { |
| 31 return test::AshTestBase::GetPrimaryShelf()->shelf_widget(); | 31 return test::AshTestBase::GetPrimaryShelf()->shelf_widget(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 ShelfLayoutManager* GetShelfLayoutManager() { | 34 ShelfLayoutManager* GetShelfLayoutManager() { |
| 35 return GetShelfWidget()->shelf_layout_manager(); | 35 return GetShelfWidget()->shelf_layout_manager(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void TestLauncherAlignment(WmWindow* root, | 38 void TestLauncherAlignment(aura::Window* root, |
| 39 ShelfAlignment alignment, | 39 ShelfAlignment alignment, |
| 40 const gfx::Rect& expected) { | 40 const gfx::Rect& expected) { |
| 41 root->GetRootWindowController()->GetShelf()->SetAlignment(alignment); | 41 GetRootWindowController(root)->GetShelf()->SetAlignment(alignment); |
| 42 EXPECT_EQ(expected.ToString(), | 42 EXPECT_EQ(expected.ToString(), display::Screen::GetScreen() |
| 43 root->GetDisplayNearestWindow().work_area().ToString()); | 43 ->GetDisplayNearestWindow(root) |
| 44 .work_area() |
| 45 .ToString()); |
| 44 } | 46 } |
| 45 | 47 |
| 46 using ShelfWidgetTest = test::AshTestBase; | 48 using ShelfWidgetTest = test::AshTestBase; |
| 47 | 49 |
| 48 TEST_F(ShelfWidgetTest, TestAlignment) { | 50 TEST_F(ShelfWidgetTest, TestAlignment) { |
| 49 UpdateDisplay("400x400"); | 51 UpdateDisplay("400x400"); |
| 50 { | 52 { |
| 51 SCOPED_TRACE("Single Bottom"); | 53 SCOPED_TRACE("Single Bottom"); |
| 52 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), | 54 TestLauncherAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_BOTTOM, |
| 53 SHELF_ALIGNMENT_BOTTOM, gfx::Rect(0, 0, 400, 352)); | 55 gfx::Rect(0, 0, 400, 352)); |
| 54 } | 56 } |
| 55 { | 57 { |
| 56 SCOPED_TRACE("Single Locked"); | 58 SCOPED_TRACE("Single Locked"); |
| 57 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), | 59 TestLauncherAlignment(Shell::GetPrimaryRootWindow(), |
| 58 SHELF_ALIGNMENT_BOTTOM_LOCKED, | 60 SHELF_ALIGNMENT_BOTTOM_LOCKED, |
| 59 gfx::Rect(0, 0, 400, 352)); | 61 gfx::Rect(0, 0, 400, 352)); |
| 60 } | 62 } |
| 61 { | 63 { |
| 62 SCOPED_TRACE("Single Right"); | 64 SCOPED_TRACE("Single Right"); |
| 63 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), | 65 TestLauncherAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT, |
| 64 SHELF_ALIGNMENT_RIGHT, gfx::Rect(0, 0, 352, 400)); | 66 gfx::Rect(0, 0, 352, 400)); |
| 65 } | 67 } |
| 66 { | 68 { |
| 67 SCOPED_TRACE("Single Left"); | 69 SCOPED_TRACE("Single Left"); |
| 68 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), | 70 TestLauncherAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT, |
| 69 SHELF_ALIGNMENT_LEFT, | |
| 70 gfx::Rect(kShelfSize, 0, 352, 400)); | 71 gfx::Rect(kShelfSize, 0, 352, 400)); |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 | 74 |
| 74 TEST_F(ShelfWidgetTest, TestAlignmentForMultipleDisplays) { | 75 TEST_F(ShelfWidgetTest, TestAlignmentForMultipleDisplays) { |
| 75 UpdateDisplay("300x300,500x500"); | 76 UpdateDisplay("300x300,500x500"); |
| 76 std::vector<WmWindow*> root_windows = ShellPort::Get()->GetAllRootWindows(); | 77 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 77 { | 78 { |
| 78 SCOPED_TRACE("Primary Bottom"); | 79 SCOPED_TRACE("Primary Bottom"); |
| 79 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM, | 80 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM, |
| 80 gfx::Rect(0, 0, 300, 252)); | 81 gfx::Rect(0, 0, 300, 252)); |
| 81 } | 82 } |
| 82 { | 83 { |
| 83 SCOPED_TRACE("Primary Locked"); | 84 SCOPED_TRACE("Primary Locked"); |
| 84 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM_LOCKED, | 85 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM_LOCKED, |
| 85 gfx::Rect(0, 0, 300, 252)); | 86 gfx::Rect(0, 0, 300, 252)); |
| 86 } | 87 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 144 } |
| 144 | 145 |
| 145 // Verifies shelf is created with correct size after user login and when its | 146 // Verifies shelf is created with correct size after user login and when its |
| 146 // container and status widget has finished sizing. | 147 // container and status widget has finished sizing. |
| 147 // See http://crbug.com/252533 | 148 // See http://crbug.com/252533 |
| 148 TEST_F(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) { | 149 TEST_F(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) { |
| 149 SetUserLoggedIn(false); | 150 SetUserLoggedIn(false); |
| 150 UpdateDisplay("300x200,400x300"); | 151 UpdateDisplay("300x200,400x300"); |
| 151 | 152 |
| 152 // Both displays have a shelf controller. | 153 // Both displays have a shelf controller. |
| 153 std::vector<WmWindow*> roots = ShellPort::Get()->GetAllRootWindows(); | 154 aura::Window::Windows roots = Shell::GetAllRootWindows(); |
| 154 WmShelf* shelf1 = WmShelf::ForWindow(roots[0]); | 155 WmShelf* shelf1 = WmShelf::ForWindow(roots[0]); |
| 155 WmShelf* shelf2 = WmShelf::ForWindow(roots[1]); | 156 WmShelf* shelf2 = WmShelf::ForWindow(roots[1]); |
| 156 ASSERT_TRUE(shelf1); | 157 ASSERT_TRUE(shelf1); |
| 157 ASSERT_TRUE(shelf2); | 158 ASSERT_TRUE(shelf2); |
| 158 | 159 |
| 159 // Both shelf controllers have a shelf widget. | 160 // Both shelf controllers have a shelf widget. |
| 160 ShelfWidget* shelf_widget1 = shelf1->shelf_widget(); | 161 ShelfWidget* shelf_widget1 = shelf1->shelf_widget(); |
| 161 ShelfWidget* shelf_widget2 = shelf2->shelf_widget(); | 162 ShelfWidget* shelf_widget2 = shelf2->shelf_widget(); |
| 162 ASSERT_TRUE(shelf_widget1); | 163 ASSERT_TRUE(shelf_widget1); |
| 163 ASSERT_TRUE(shelf_widget2); | 164 ASSERT_TRUE(shelf_widget2); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 } | 399 } |
| 399 | 400 |
| 400 TEST_F(ShelfWidgetAfterLoginTest, CreateLockedShelf) { | 401 TEST_F(ShelfWidgetAfterLoginTest, CreateLockedShelf) { |
| 401 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. | 402 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. |
| 402 TestShelf(SHELF_ALIGNMENT_BOTTOM_LOCKED, SHELF_AUTO_HIDE_BEHAVIOR_NEVER, | 403 TestShelf(SHELF_ALIGNMENT_BOTTOM_LOCKED, SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
| 403 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); | 404 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); |
| 404 } | 405 } |
| 405 | 406 |
| 406 } // namespace | 407 } // namespace |
| 407 } // namespace ash | 408 } // namespace ash |
| OLD | NEW |