Chromium Code Reviews| 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 21 matching lines...) Expand all Loading... | |
| 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 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 using ShelfWidgetTest = test::AshTestBase; | 40 using ShelfWidgetTest = test::AshTestBase; |
| 41 | 41 |
| 42 void TestLauncherAlignment(WmWindow* root, | 42 void TestLauncherAlignment(aura::Window* root, |
| 43 ShelfAlignment alignment, | 43 ShelfAlignment alignment, |
| 44 const gfx::Rect& expected) { | 44 const gfx::Rect& expected) { |
| 45 root->GetRootWindowController()->GetShelf()->SetAlignment(alignment); | 45 GetRootWindowController(root)->GetShelf()->SetAlignment(alignment); |
| 46 EXPECT_EQ(expected.ToString(), | 46 EXPECT_EQ(expected.ToString(), display::Screen::GetScreen() |
| 47 root->GetDisplayNearestWindow().work_area().ToString()); | 47 ->GetDisplayNearestWindow(root) |
|
James Cook
2017/05/17 23:41:49
Aside: I really miss window->GetDisplayNearestWind
msw
2017/05/18 20:28:00
Ditto, I think this is worth separate consideratio
| |
| 48 .work_area() | |
| 49 .ToString()); | |
| 48 } | 50 } |
| 49 | 51 |
| 50 TEST_F(ShelfWidgetTest, TestAlignment) { | 52 TEST_F(ShelfWidgetTest, TestAlignment) { |
| 51 UpdateDisplay("400x400"); | 53 UpdateDisplay("400x400"); |
| 52 { | 54 { |
| 53 SCOPED_TRACE("Single Bottom"); | 55 SCOPED_TRACE("Single Bottom"); |
| 54 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), | 56 TestLauncherAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_BOTTOM, |
| 55 SHELF_ALIGNMENT_BOTTOM, gfx::Rect(0, 0, 400, 352)); | 57 gfx::Rect(0, 0, 400, 352)); |
| 56 } | 58 } |
| 57 { | 59 { |
| 58 SCOPED_TRACE("Single Locked"); | 60 SCOPED_TRACE("Single Locked"); |
| 59 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), | 61 TestLauncherAlignment(Shell::GetPrimaryRootWindow(), |
| 60 SHELF_ALIGNMENT_BOTTOM_LOCKED, | 62 SHELF_ALIGNMENT_BOTTOM_LOCKED, |
| 61 gfx::Rect(0, 0, 400, 352)); | 63 gfx::Rect(0, 0, 400, 352)); |
| 62 } | 64 } |
| 63 { | 65 { |
| 64 SCOPED_TRACE("Single Right"); | 66 SCOPED_TRACE("Single Right"); |
| 65 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), | 67 TestLauncherAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT, |
| 66 SHELF_ALIGNMENT_RIGHT, gfx::Rect(0, 0, 352, 400)); | 68 gfx::Rect(0, 0, 352, 400)); |
| 67 } | 69 } |
| 68 { | 70 { |
| 69 SCOPED_TRACE("Single Left"); | 71 SCOPED_TRACE("Single Left"); |
| 70 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), | 72 TestLauncherAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT, |
| 71 SHELF_ALIGNMENT_LEFT, | |
| 72 gfx::Rect(kShelfSize, 0, 352, 400)); | 73 gfx::Rect(kShelfSize, 0, 352, 400)); |
| 73 } | 74 } |
| 74 } | 75 } |
| 75 | 76 |
| 76 TEST_F(ShelfWidgetTest, TestAlignmentForMultipleDisplays) { | 77 TEST_F(ShelfWidgetTest, TestAlignmentForMultipleDisplays) { |
| 77 UpdateDisplay("300x300,500x500"); | 78 UpdateDisplay("300x300,500x500"); |
| 78 std::vector<WmWindow*> root_windows = ShellPort::Get()->GetAllRootWindows(); | 79 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 79 { | 80 { |
| 80 SCOPED_TRACE("Primary Bottom"); | 81 SCOPED_TRACE("Primary Bottom"); |
| 81 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM, | 82 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM, |
| 82 gfx::Rect(0, 0, 300, 252)); | 83 gfx::Rect(0, 0, 300, 252)); |
| 83 } | 84 } |
| 84 { | 85 { |
| 85 SCOPED_TRACE("Primary Locked"); | 86 SCOPED_TRACE("Primary Locked"); |
| 86 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM_LOCKED, | 87 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM_LOCKED, |
| 87 gfx::Rect(0, 0, 300, 252)); | 88 gfx::Rect(0, 0, 300, 252)); |
| 88 } | 89 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 } | 146 } |
| 146 | 147 |
| 147 // Verifies shelf is created with correct size after user login and when its | 148 // Verifies shelf is created with correct size after user login and when its |
| 148 // container and status widget has finished sizing. | 149 // container and status widget has finished sizing. |
| 149 // See http://crbug.com/252533 | 150 // See http://crbug.com/252533 |
| 150 TEST_F(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) { | 151 TEST_F(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) { |
| 151 SetUserLoggedIn(false); | 152 SetUserLoggedIn(false); |
| 152 UpdateDisplay("300x200,400x300"); | 153 UpdateDisplay("300x200,400x300"); |
| 153 | 154 |
| 154 // Both displays have a shelf controller. | 155 // Both displays have a shelf controller. |
| 155 std::vector<WmWindow*> roots = ShellPort::Get()->GetAllRootWindows(); | 156 aura::Window::Windows roots = Shell::GetAllRootWindows(); |
| 156 WmShelf* shelf1 = WmShelf::ForWindow(roots[0]); | 157 WmShelf* shelf1 = WmShelf::ForWindow(roots[0]); |
| 157 WmShelf* shelf2 = WmShelf::ForWindow(roots[1]); | 158 WmShelf* shelf2 = WmShelf::ForWindow(roots[1]); |
| 158 ASSERT_TRUE(shelf1); | 159 ASSERT_TRUE(shelf1); |
| 159 ASSERT_TRUE(shelf2); | 160 ASSERT_TRUE(shelf2); |
| 160 | 161 |
| 161 // Both shelf controllers have a shelf widget. | 162 // Both shelf controllers have a shelf widget. |
| 162 ShelfWidget* shelf_widget1 = shelf1->shelf_widget(); | 163 ShelfWidget* shelf_widget1 = shelf1->shelf_widget(); |
| 163 ShelfWidget* shelf_widget2 = shelf2->shelf_widget(); | 164 ShelfWidget* shelf_widget2 = shelf2->shelf_widget(); |
| 164 ASSERT_TRUE(shelf_widget1); | 165 ASSERT_TRUE(shelf_widget1); |
| 165 ASSERT_TRUE(shelf_widget2); | 166 ASSERT_TRUE(shelf_widget2); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 } | 409 } |
| 409 | 410 |
| 410 TEST_F(ShelfWidgetTestWithInitializer, CreateLockedShelf) { | 411 TEST_F(ShelfWidgetTestWithInitializer, CreateLockedShelf) { |
| 411 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. | 412 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. |
| 412 TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM_LOCKED, | 413 TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM_LOCKED, |
| 413 SHELF_AUTO_HIDE_BEHAVIOR_NEVER, | 414 SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
| 414 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); | 415 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); |
| 415 } | 416 } |
| 416 | 417 |
| 417 } // namespace ash | 418 } // namespace ash |
| OLD | NEW |