| 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" |
| 11 #include "ash/shelf/wm_shelf.h" | 11 #include "ash/shelf/wm_shelf.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/shell_port.h" |
| 13 #include "ash/system/status_area_widget.h" | 14 #include "ash/system/status_area_widget.h" |
| 14 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
| 15 #include "ash/test/ash_test_helper.h" | 16 #include "ash/test/ash_test_helper.h" |
| 16 #include "ash/test/shelf_view_test_api.h" | 17 #include "ash/test/shelf_view_test_api.h" |
| 17 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
| 18 #include "ash/wm_shell.h" | |
| 19 #include "ash/wm_window.h" | 19 #include "ash/wm_window.h" |
| 20 #include "ui/aura/window_event_dispatcher.h" | 20 #include "ui/aura/window_event_dispatcher.h" |
| 21 #include "ui/display/display.h" | 21 #include "ui/display/display.h" |
| 22 #include "ui/events/event_utils.h" | 22 #include "ui/events/event_utils.h" |
| 23 #include "ui/views/view.h" | 23 #include "ui/views/view.h" |
| 24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 25 | 25 |
| 26 namespace ash { | 26 namespace ash { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 45 root->GetRootWindowController()->GetShelf()->SetAlignment(alignment); | 45 root->GetRootWindowController()->GetShelf()->SetAlignment(alignment); |
| 46 EXPECT_EQ(expected.ToString(), | 46 EXPECT_EQ(expected.ToString(), |
| 47 root->GetDisplayNearestWindow().work_area().ToString()); | 47 root->GetDisplayNearestWindow().work_area().ToString()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 TEST_F(ShelfWidgetTest, TestAlignment) { | 50 TEST_F(ShelfWidgetTest, TestAlignment) { |
| 51 const int kShelfSize = GetShelfConstant(SHELF_SIZE); | 51 const int kShelfSize = GetShelfConstant(SHELF_SIZE); |
| 52 UpdateDisplay("400x400"); | 52 UpdateDisplay("400x400"); |
| 53 { | 53 { |
| 54 SCOPED_TRACE("Single Bottom"); | 54 SCOPED_TRACE("Single Bottom"); |
| 55 TestLauncherAlignment(WmShell::Get()->GetPrimaryRootWindow(), | 55 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), |
| 56 SHELF_ALIGNMENT_BOTTOM, gfx::Rect(0, 0, 400, 352)); | 56 SHELF_ALIGNMENT_BOTTOM, gfx::Rect(0, 0, 400, 352)); |
| 57 } | 57 } |
| 58 { | 58 { |
| 59 SCOPED_TRACE("Single Locked"); | 59 SCOPED_TRACE("Single Locked"); |
| 60 TestLauncherAlignment(WmShell::Get()->GetPrimaryRootWindow(), | 60 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), |
| 61 SHELF_ALIGNMENT_BOTTOM_LOCKED, | 61 SHELF_ALIGNMENT_BOTTOM_LOCKED, |
| 62 gfx::Rect(0, 0, 400, 352)); | 62 gfx::Rect(0, 0, 400, 352)); |
| 63 } | 63 } |
| 64 { | 64 { |
| 65 SCOPED_TRACE("Single Right"); | 65 SCOPED_TRACE("Single Right"); |
| 66 TestLauncherAlignment(WmShell::Get()->GetPrimaryRootWindow(), | 66 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), |
| 67 SHELF_ALIGNMENT_RIGHT, gfx::Rect(0, 0, 352, 400)); | 67 SHELF_ALIGNMENT_RIGHT, gfx::Rect(0, 0, 352, 400)); |
| 68 } | 68 } |
| 69 { | 69 { |
| 70 SCOPED_TRACE("Single Left"); | 70 SCOPED_TRACE("Single Left"); |
| 71 TestLauncherAlignment(WmShell::Get()->GetPrimaryRootWindow(), | 71 TestLauncherAlignment(ShellPort::Get()->GetPrimaryRootWindow(), |
| 72 SHELF_ALIGNMENT_LEFT, | 72 SHELF_ALIGNMENT_LEFT, |
| 73 gfx::Rect(kShelfSize, 0, 352, 400)); | 73 gfx::Rect(kShelfSize, 0, 352, 400)); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 TEST_F(ShelfWidgetTest, TestAlignmentForMultipleDisplays) { | 77 TEST_F(ShelfWidgetTest, TestAlignmentForMultipleDisplays) { |
| 78 const int kShelfSize = GetShelfConstant(SHELF_SIZE); | 78 const int kShelfSize = GetShelfConstant(SHELF_SIZE); |
| 79 UpdateDisplay("300x300,500x500"); | 79 UpdateDisplay("300x300,500x500"); |
| 80 std::vector<WmWindow*> root_windows = WmShell::Get()->GetAllRootWindows(); | 80 std::vector<WmWindow*> root_windows = ShellPort::Get()->GetAllRootWindows(); |
| 81 { | 81 { |
| 82 SCOPED_TRACE("Primary Bottom"); | 82 SCOPED_TRACE("Primary Bottom"); |
| 83 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM, | 83 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM, |
| 84 gfx::Rect(0, 0, 300, 252)); | 84 gfx::Rect(0, 0, 300, 252)); |
| 85 } | 85 } |
| 86 { | 86 { |
| 87 SCOPED_TRACE("Primary Locked"); | 87 SCOPED_TRACE("Primary Locked"); |
| 88 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM_LOCKED, | 88 TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM_LOCKED, |
| 89 gfx::Rect(0, 0, 300, 252)); | 89 gfx::Rect(0, 0, 300, 252)); |
| 90 } | 90 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Verifies shelf is created with correct size after user login and when its | 149 // Verifies shelf is created with correct size after user login and when its |
| 150 // container and status widget has finished sizing. | 150 // container and status widget has finished sizing. |
| 151 // See http://crbug.com/252533 | 151 // See http://crbug.com/252533 |
| 152 TEST_F(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) { | 152 TEST_F(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) { |
| 153 SetUserLoggedIn(false); | 153 SetUserLoggedIn(false); |
| 154 UpdateDisplay("300x200,400x300"); | 154 UpdateDisplay("300x200,400x300"); |
| 155 | 155 |
| 156 // Both displays have a shelf controller. | 156 // Both displays have a shelf controller. |
| 157 std::vector<WmWindow*> roots = WmShell::Get()->GetAllRootWindows(); | 157 std::vector<WmWindow*> roots = ShellPort::Get()->GetAllRootWindows(); |
| 158 WmShelf* shelf1 = WmShelf::ForWindow(roots[0]); | 158 WmShelf* shelf1 = WmShelf::ForWindow(roots[0]); |
| 159 WmShelf* shelf2 = WmShelf::ForWindow(roots[1]); | 159 WmShelf* shelf2 = WmShelf::ForWindow(roots[1]); |
| 160 ASSERT_TRUE(shelf1); | 160 ASSERT_TRUE(shelf1); |
| 161 ASSERT_TRUE(shelf2); | 161 ASSERT_TRUE(shelf2); |
| 162 | 162 |
| 163 // Both shelf controllers have a shelf widget. | 163 // Both shelf controllers have a shelf widget. |
| 164 ShelfWidget* shelf_widget1 = shelf1->shelf_widget(); | 164 ShelfWidget* shelf_widget1 = shelf1->shelf_widget(); |
| 165 ShelfWidget* shelf_widget2 = shelf2->shelf_widget(); | 165 ShelfWidget* shelf_widget2 = shelf2->shelf_widget(); |
| 166 ASSERT_TRUE(shelf_widget1); | 166 ASSERT_TRUE(shelf_widget1); |
| 167 ASSERT_TRUE(shelf_widget2); | 167 ASSERT_TRUE(shelf_widget2); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 } | 410 } |
| 411 | 411 |
| 412 TEST_F(ShelfWidgetTestWithInitializer, CreateLockedShelf) { | 412 TEST_F(ShelfWidgetTestWithInitializer, CreateLockedShelf) { |
| 413 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. | 413 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. |
| 414 TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM_LOCKED, | 414 TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM_LOCKED, |
| 415 SHELF_AUTO_HIDE_BEHAVIOR_NEVER, | 415 SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
| 416 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); | 416 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); |
| 417 } | 417 } |
| 418 | 418 |
| 419 } // namespace ash | 419 } // namespace ash |
| OLD | NEW |