| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/accelerators/accelerator_table.h" | 8 #include "ash/accelerators/accelerator_table.h" |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| 11 #include "ash/focus_cycler.h" | 11 #include "ash/focus_cycler.h" |
| 12 #include "ash/launcher/launcher.h" | |
| 13 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
| 14 #include "ash/screen_ash.h" | 13 #include "ash/screen_ash.h" |
| 15 #include "ash/session_state_delegate.h" | 14 #include "ash/session_state_delegate.h" |
| 15 #include "ash/shelf/shelf.h" |
| 16 #include "ash/shelf/shelf_layout_manager_observer.h" | 16 #include "ash/shelf/shelf_layout_manager_observer.h" |
| 17 #include "ash/shelf/shelf_view.h" | 17 #include "ash/shelf/shelf_view.h" |
| 18 #include "ash/shelf/shelf_widget.h" | 18 #include "ash/shelf/shelf_widget.h" |
| 19 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 20 #include "ash/shell_window_ids.h" | 20 #include "ash/shell_window_ids.h" |
| 21 #include "ash/system/status_area_widget.h" | 21 #include "ash/system/status_area_widget.h" |
| 22 #include "ash/system/tray/system_tray.h" | 22 #include "ash/system/tray/system_tray.h" |
| 23 #include "ash/system/tray/system_tray_item.h" | 23 #include "ash/system/tray/system_tray_item.h" |
| 24 #include "ash/test/ash_test_base.h" | 24 #include "ash/test/ash_test_base.h" |
| 25 #include "ash/test/launcher_test_api.h" | 25 #include "ash/test/shelf_test_api.h" |
| 26 #include "ash/wm/window_state.h" | 26 #include "ash/wm/window_state.h" |
| 27 #include "ash/wm/window_util.h" | 27 #include "ash/wm/window_util.h" |
| 28 #include "base/command_line.h" | 28 #include "base/command_line.h" |
| 29 #include "base/strings/utf_string_conversions.h" | 29 #include "base/strings/utf_string_conversions.h" |
| 30 #include "ui/aura/client/aura_constants.h" | 30 #include "ui/aura/client/aura_constants.h" |
| 31 #include "ui/aura/root_window.h" | 31 #include "ui/aura/root_window.h" |
| 32 #include "ui/aura/test/event_generator.h" | 32 #include "ui/aura/test/event_generator.h" |
| 33 #include "ui/aura/window.h" | 33 #include "ui/aura/window.h" |
| 34 #include "ui/compositor/layer.h" | 34 #include "ui/compositor/layer.h" |
| 35 #include "ui/compositor/layer_animator.h" | 35 #include "ui/compositor/layer_animator.h" |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 // Makes sure SetVisible updates work area and widget appropriately. | 662 // Makes sure SetVisible updates work area and widget appropriately. |
| 663 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { | 663 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { |
| 664 ShelfWidget* shelf = GetShelfWidget(); | 664 ShelfWidget* shelf = GetShelfWidget(); |
| 665 ShelfLayoutManager* manager = shelf->shelf_layout_manager(); | 665 ShelfLayoutManager* manager = shelf->shelf_layout_manager(); |
| 666 // Force an initial layout. | 666 // Force an initial layout. |
| 667 manager->LayoutShelf(); | 667 manager->LayoutShelf(); |
| 668 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); | 668 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
| 669 | 669 |
| 670 gfx::Rect status_bounds( | 670 gfx::Rect status_bounds( |
| 671 shelf->status_area_widget()->GetWindowBoundsInScreen()); | 671 shelf->status_area_widget()->GetWindowBoundsInScreen()); |
| 672 gfx::Rect launcher_bounds( | 672 gfx::Rect shelf_bounds( |
| 673 shelf->GetWindowBoundsInScreen()); | 673 shelf->GetWindowBoundsInScreen()); |
| 674 int shelf_height = manager->GetIdealBounds().height(); | 674 int shelf_height = manager->GetIdealBounds().height(); |
| 675 gfx::Screen* screen = Shell::GetScreen(); | 675 gfx::Screen* screen = Shell::GetScreen(); |
| 676 gfx::Display display = screen->GetDisplayNearestWindow( | 676 gfx::Display display = screen->GetDisplayNearestWindow( |
| 677 Shell::GetPrimaryRootWindow()); | 677 Shell::GetPrimaryRootWindow()); |
| 678 ASSERT_NE(-1, display.id()); | 678 ASSERT_NE(-1, display.id()); |
| 679 // Bottom inset should be the max of widget heights. | 679 // Bottom inset should be the max of widget heights. |
| 680 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); | 680 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
| 681 | 681 |
| 682 // Hide the shelf. | 682 // Hide the shelf. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 700 SetState(manager, SHELF_VISIBLE); | 700 SetState(manager, SHELF_VISIBLE); |
| 701 // Run the animation to completion. | 701 // Run the animation to completion. |
| 702 StepWidgetLayerAnimatorToEnd(shelf); | 702 StepWidgetLayerAnimatorToEnd(shelf); |
| 703 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); | 703 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); |
| 704 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); | 704 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
| 705 display = screen->GetDisplayNearestWindow( | 705 display = screen->GetDisplayNearestWindow( |
| 706 Shell::GetPrimaryRootWindow()); | 706 Shell::GetPrimaryRootWindow()); |
| 707 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); | 707 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
| 708 | 708 |
| 709 // Make sure the bounds of the two widgets changed. | 709 // Make sure the bounds of the two widgets changed. |
| 710 launcher_bounds = shelf->GetNativeView()->bounds(); | 710 shelf_bounds = shelf->GetNativeView()->bounds(); |
| 711 EXPECT_LT(launcher_bounds.y(), | 711 EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); |
| 712 screen->GetPrimaryDisplay().bounds().bottom()); | |
| 713 status_bounds = shelf->status_area_widget()->GetNativeView()->bounds(); | 712 status_bounds = shelf->status_area_widget()->GetNativeView()->bounds(); |
| 714 EXPECT_LT(status_bounds.y(), | 713 EXPECT_LT(status_bounds.y(), |
| 715 screen->GetPrimaryDisplay().bounds().bottom()); | 714 screen->GetPrimaryDisplay().bounds().bottom()); |
| 716 } | 715 } |
| 717 | 716 |
| 718 // Makes sure shelf alignment is correct for lock screen. | 717 // Makes sure shelf alignment is correct for lock screen. |
| 719 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLockScreen) { | 718 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLockScreen) { |
| 720 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); | 719 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); |
| 721 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); | 720 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 722 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); | 721 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 | 767 |
| 769 const int small_change = initial_shelf_bounds.height() / 2; | 768 const int small_change = initial_shelf_bounds.height() / 2; |
| 770 EXPECT_LE( | 769 EXPECT_LE( |
| 771 std::abs(initial_shelf_bounds.height() - current_shelf_bounds.height()), | 770 std::abs(initial_shelf_bounds.height() - current_shelf_bounds.height()), |
| 772 small_change); | 771 small_change); |
| 773 EXPECT_LE( | 772 EXPECT_LE( |
| 774 std::abs(initial_status_bounds.height() - current_status_bounds.height()), | 773 std::abs(initial_status_bounds.height() - current_status_bounds.height()), |
| 775 small_change); | 774 small_change); |
| 776 } | 775 } |
| 777 | 776 |
| 778 // Makes sure the launcher is sized when the status area changes size. | 777 // Makes sure the shelf is sized when the status area changes size. |
| 779 TEST_F(ShelfLayoutManagerTest, LauncherUpdatedWhenStatusAreaChangesSize) { | 778 TEST_F(ShelfLayoutManagerTest, ShelfUpdatedWhenStatusAreaChangesSize) { |
| 780 Launcher* launcher = Launcher::ForPrimaryDisplay(); | 779 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 781 ASSERT_TRUE(launcher); | 780 ASSERT_TRUE(shelf); |
| 782 ShelfWidget* shelf_widget = GetShelfWidget(); | 781 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 783 ASSERT_TRUE(shelf_widget); | 782 ASSERT_TRUE(shelf_widget); |
| 784 ASSERT_TRUE(shelf_widget->status_area_widget()); | 783 ASSERT_TRUE(shelf_widget->status_area_widget()); |
| 785 shelf_widget->status_area_widget()->SetBounds( | 784 shelf_widget->status_area_widget()->SetBounds( |
| 786 gfx::Rect(0, 0, 200, 200)); | 785 gfx::Rect(0, 0, 200, 200)); |
| 787 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - | 786 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - |
| 788 test::LauncherTestAPI(launcher).shelf_view()->width()); | 787 test::ShelfTestAPI(shelf).shelf_view()->width()); |
| 789 } | 788 } |
| 790 | 789 |
| 791 | 790 |
| 792 #if defined(OS_WIN) | 791 #if defined(OS_WIN) |
| 793 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 792 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 794 #define MAYBE_AutoHide DISABLED_AutoHide | 793 #define MAYBE_AutoHide DISABLED_AutoHide |
| 795 #else | 794 #else |
| 796 #define MAYBE_AutoHide AutoHide | 795 #define MAYBE_AutoHide AutoHide |
| 797 #endif | 796 #endif |
| 798 | 797 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 809 params.bounds = gfx::Rect(0, 0, 200, 200); | 808 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 810 params.context = CurrentContext(); | 809 params.context = CurrentContext(); |
| 811 // Widget is now owned by the parent window. | 810 // Widget is now owned by the parent window. |
| 812 widget->Init(params); | 811 widget->Init(params); |
| 813 widget->Maximize(); | 812 widget->Maximize(); |
| 814 widget->Show(); | 813 widget->Show(); |
| 815 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 814 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 816 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 815 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 817 | 816 |
| 818 // LayoutShelf() forces the animation to completion, at which point the | 817 // LayoutShelf() forces the animation to completion, at which point the |
| 819 // launcher should go off the screen. | 818 // shelf should go off the screen. |
| 820 shelf->LayoutShelf(); | 819 shelf->LayoutShelf(); |
| 821 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 820 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 822 GetShelfWidget()->GetWindowBoundsInScreen().y()); | 821 GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 823 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 822 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 824 Shell::GetScreen()->GetDisplayNearestWindow( | 823 Shell::GetScreen()->GetDisplayNearestWindow( |
| 825 root).work_area().bottom()); | 824 root).work_area().bottom()); |
| 826 | 825 |
| 827 // Move the mouse to the bottom of the screen. | 826 // Move the mouse to the bottom of the screen. |
| 828 generator.MoveMouseTo(0, root->bounds().bottom() - 1); | 827 generator.MoveMouseTo(0, root->bounds().bottom() - 1); |
| 829 | 828 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 params.context = CurrentContext(); | 969 params.context = CurrentContext(); |
| 971 // Widget is now owned by the parent window. | 970 // Widget is now owned by the parent window. |
| 972 widget->Init(params); | 971 widget->Init(params); |
| 973 widget->Maximize(); | 972 widget->Maximize(); |
| 974 widget->Show(); | 973 widget->Show(); |
| 975 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 974 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 976 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 975 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 977 | 976 |
| 978 aura::Window* root = Shell::GetPrimaryRootWindow(); | 977 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 979 // LayoutShelf() forces the animation to completion, at which point the | 978 // LayoutShelf() forces the animation to completion, at which point the |
| 980 // launcher should go off the screen. | 979 // shelf should go off the screen. |
| 981 shelf->LayoutShelf(); | 980 shelf->LayoutShelf(); |
| 982 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 981 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 983 GetShelfWidget()->GetWindowBoundsInScreen().y()); | 982 GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 984 | 983 |
| 985 aura::Window* lock_container = Shell::GetContainer( | 984 aura::Window* lock_container = Shell::GetContainer( |
| 986 Shell::GetPrimaryRootWindow(), | 985 Shell::GetPrimaryRootWindow(), |
| 987 internal::kShellWindowId_LockScreenContainer); | 986 internal::kShellWindowId_LockScreenContainer); |
| 988 | 987 |
| 989 views::Widget* lock_widget = new views::Widget; | 988 views::Widget* lock_widget = new views::Widget; |
| 990 views::Widget::InitParams lock_params( | 989 views::Widget::InitParams lock_params( |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1189 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1191 shelf->shelf_widget()->ForceUndimming(true); | 1190 shelf->shelf_widget()->ForceUndimming(true); |
| 1192 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | 1191 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); |
| 1193 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1192 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1194 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | 1193 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); |
| 1195 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1194 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1196 shelf->shelf_widget()->ForceUndimming(true); | 1195 shelf->shelf_widget()->ForceUndimming(true); |
| 1197 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1196 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1198 } | 1197 } |
| 1199 | 1198 |
| 1200 // Verifies the shelf is visible when status/launcher is focused. | 1199 // Verifies the shelf is visible when status/shelf is focused. |
| 1201 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) { | 1200 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { |
| 1202 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1201 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 1203 // it isn't over the shelf. | 1202 // it isn't over the shelf. |
| 1204 aura::test::EventGenerator generator( | 1203 aura::test::EventGenerator generator( |
| 1205 Shell::GetPrimaryRootWindow(), gfx::Point()); | 1204 Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 1206 generator.MoveMouseTo(0, 0); | 1205 generator.MoveMouseTo(0, 0); |
| 1207 | 1206 |
| 1208 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1207 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1209 views::Widget* widget = new views::Widget; | 1208 views::Widget* widget = new views::Widget; |
| 1210 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1209 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 1211 params.bounds = gfx::Rect(0, 0, 200, 200); | 1210 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 1212 params.context = CurrentContext(); | 1211 params.context = CurrentContext(); |
| 1213 // Widget is now owned by the parent window. | 1212 // Widget is now owned by the parent window. |
| 1214 widget->Init(params); | 1213 widget->Init(params); |
| 1215 widget->Show(); | 1214 widget->Show(); |
| 1216 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1215 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1217 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1216 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1218 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1217 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1219 | 1218 |
| 1220 // Focus the launcher. Have to go through the focus cycler as normal focus | 1219 // Focus the shelf. Have to go through the focus cycler as normal focus |
| 1221 // requests to it do nothing. | 1220 // requests to it do nothing. |
| 1222 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); | 1221 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); |
| 1223 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1222 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 1224 | 1223 |
| 1225 widget->Activate(); | 1224 widget->Activate(); |
| 1226 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1225 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1227 | 1226 |
| 1228 // Trying to activate the status should fail, since we only allow activating | 1227 // Trying to activate the status should fail, since we only allow activating |
| 1229 // it when the user is using the keyboard (i.e. through FocusCycler). | 1228 // it when the user is using the keyboard (i.e. through FocusCycler). |
| 1230 GetShelfWidget()->status_area_widget()->Activate(); | 1229 GetShelfWidget()->status_area_widget()->Activate(); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 | 1396 |
| 1398 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT, TOP). | 1397 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT, TOP). |
| 1399 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { | 1398 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { |
| 1400 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1399 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1401 // Force an initial layout. | 1400 // Force an initial layout. |
| 1402 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1401 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1403 shelf->LayoutShelf(); | 1402 shelf->LayoutShelf(); |
| 1404 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1403 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 1405 | 1404 |
| 1406 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 1405 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 1407 gfx::Rect launcher_bounds( | 1406 gfx::Rect shelf_bounds( |
| 1408 GetShelfWidget()->GetWindowBoundsInScreen()); | 1407 GetShelfWidget()->GetWindowBoundsInScreen()); |
| 1409 const gfx::Screen* screen = Shell::GetScreen(); | 1408 const gfx::Screen* screen = Shell::GetScreen(); |
| 1410 gfx::Display display = | 1409 gfx::Display display = |
| 1411 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1410 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1412 ASSERT_NE(-1, display.id()); | 1411 ASSERT_NE(-1, display.id()); |
| 1413 EXPECT_EQ(shelf->GetIdealBounds().width(), | 1412 EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 1414 display.GetWorkAreaInsets().left()); | 1413 display.GetWorkAreaInsets().left()); |
| 1415 EXPECT_GE( | 1414 EXPECT_GE( |
| 1416 launcher_bounds.width(), | 1415 shelf_bounds.width(), |
| 1417 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); | 1416 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); |
| 1418 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); | 1417 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); |
| 1419 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); | 1418 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
| 1420 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); | 1419 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 1421 EXPECT_GE(status_bounds.width(), | 1420 EXPECT_GE(status_bounds.width(), |
| 1422 status_area_widget->GetContentsView()->GetPreferredSize().width()); | 1421 status_area_widget->GetContentsView()->GetPreferredSize().width()); |
| 1423 EXPECT_EQ(shelf->GetIdealBounds().width(), | 1422 EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 1424 display.GetWorkAreaInsets().left()); | 1423 display.GetWorkAreaInsets().left()); |
| 1425 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); | 1424 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
| 1426 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 1425 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 1427 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); | 1426 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); |
| 1428 EXPECT_EQ(display.bounds().x(), launcher_bounds.x()); | 1427 EXPECT_EQ(display.bounds().x(), shelf_bounds.x()); |
| 1429 EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); | 1428 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); |
| 1430 EXPECT_EQ(display.bounds().height(), launcher_bounds.height()); | 1429 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); |
| 1431 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1430 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1432 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1431 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1433 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, | 1432 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1434 display.GetWorkAreaInsets().left()); | 1433 display.GetWorkAreaInsets().left()); |
| 1435 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, display.work_area().x()); | 1434 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, display.work_area().x()); |
| 1436 | 1435 |
| 1437 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1436 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1438 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 1437 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 1439 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1438 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1440 launcher_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 1439 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 1441 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1440 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1442 ASSERT_NE(-1, display.id()); | 1441 ASSERT_NE(-1, display.id()); |
| 1443 EXPECT_EQ(shelf->GetIdealBounds().width(), | 1442 EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 1444 display.GetWorkAreaInsets().right()); | 1443 display.GetWorkAreaInsets().right()); |
| 1445 EXPECT_GE(launcher_bounds.width(), | 1444 EXPECT_GE(shelf_bounds.width(), |
| 1446 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); | 1445 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); |
| 1447 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment()); | 1446 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment()); |
| 1448 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); | 1447 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); |
| 1449 EXPECT_GE(status_bounds.width(), | 1448 EXPECT_GE(status_bounds.width(), |
| 1450 status_area_widget->GetContentsView()->GetPreferredSize().width()); | 1449 status_area_widget->GetContentsView()->GetPreferredSize().width()); |
| 1451 EXPECT_EQ(shelf->GetIdealBounds().width(), | 1450 EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 1452 display.GetWorkAreaInsets().right()); | 1451 display.GetWorkAreaInsets().right()); |
| 1453 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); | 1452 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
| 1454 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 1453 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 1455 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); | 1454 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); |
| 1456 EXPECT_EQ(display.work_area().right(), launcher_bounds.x()); | 1455 EXPECT_EQ(display.work_area().right(), shelf_bounds.x()); |
| 1457 EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); | 1456 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); |
| 1458 EXPECT_EQ(display.bounds().height(), launcher_bounds.height()); | 1457 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); |
| 1459 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1458 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1460 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1459 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1461 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, | 1460 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1462 display.GetWorkAreaInsets().right()); | 1461 display.GetWorkAreaInsets().right()); |
| 1463 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, | 1462 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1464 display.bounds().right() - display.work_area().right()); | 1463 display.bounds().right() - display.work_area().right()); |
| 1465 | 1464 |
| 1466 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1465 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1467 shelf->SetAlignment(SHELF_ALIGNMENT_TOP); | 1466 shelf->SetAlignment(SHELF_ALIGNMENT_TOP); |
| 1468 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1467 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1469 launcher_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 1468 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 1470 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1469 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1471 ASSERT_NE(-1, display.id()); | 1470 ASSERT_NE(-1, display.id()); |
| 1472 EXPECT_EQ(shelf->GetIdealBounds().height(), | 1471 EXPECT_EQ(shelf->GetIdealBounds().height(), |
| 1473 display.GetWorkAreaInsets().top()); | 1472 display.GetWorkAreaInsets().top()); |
| 1474 EXPECT_GE(launcher_bounds.height(), | 1473 EXPECT_GE(shelf_bounds.height(), |
| 1475 GetShelfWidget()->GetContentsView()->GetPreferredSize().height()); | 1474 GetShelfWidget()->GetContentsView()->GetPreferredSize().height()); |
| 1476 EXPECT_EQ(SHELF_ALIGNMENT_TOP, GetSystemTray()->shelf_alignment()); | 1475 EXPECT_EQ(SHELF_ALIGNMENT_TOP, GetSystemTray()->shelf_alignment()); |
| 1477 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); | 1476 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); |
| 1478 EXPECT_GE(status_bounds.height(), | 1477 EXPECT_GE(status_bounds.height(), |
| 1479 status_area_widget->GetContentsView()->GetPreferredSize().height()); | 1478 status_area_widget->GetContentsView()->GetPreferredSize().height()); |
| 1480 EXPECT_EQ(shelf->GetIdealBounds().height(), | 1479 EXPECT_EQ(shelf->GetIdealBounds().height(), |
| 1481 display.GetWorkAreaInsets().top()); | 1480 display.GetWorkAreaInsets().top()); |
| 1482 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); | 1481 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); |
| 1483 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 1482 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 1484 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); | 1483 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); |
| 1485 EXPECT_EQ(display.work_area().y(), launcher_bounds.bottom()); | 1484 EXPECT_EQ(display.work_area().y(), shelf_bounds.bottom()); |
| 1486 EXPECT_EQ(display.bounds().x(), launcher_bounds.x()); | 1485 EXPECT_EQ(display.bounds().x(), shelf_bounds.x()); |
| 1487 EXPECT_EQ(display.bounds().width(), launcher_bounds.width()); | 1486 EXPECT_EQ(display.bounds().width(), shelf_bounds.width()); |
| 1488 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1487 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1489 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1488 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1490 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, | 1489 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1491 display.GetWorkAreaInsets().top()); | 1490 display.GetWorkAreaInsets().top()); |
| 1492 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, | 1491 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1493 display.work_area().y() - display.bounds().y()); | 1492 display.work_area().y() - display.bounds().y()); |
| 1494 } | 1493 } |
| 1495 | 1494 |
| 1496 #if defined(OS_WIN) | 1495 #if defined(OS_WIN) |
| 1497 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 1496 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1917 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 1916 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 1918 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 1917 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 1919 generator.ClickLeftButton(); | 1918 generator.ClickLeftButton(); |
| 1920 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 1919 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 1921 generator.ClickLeftButton(); | 1920 generator.ClickLeftButton(); |
| 1922 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 1921 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 1923 } | 1922 } |
| 1924 | 1923 |
| 1925 } // namespace internal | 1924 } // namespace internal |
| 1926 } // namespace ash | 1925 } // namespace ash |
| OLD | NEW |