| 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/wm/shelf_layout_manager.h" | 5 #include "ash/wm/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/focus_cycler.h" | 11 #include "ash/focus_cycler.h" |
| 11 #include "ash/launcher/launcher.h" | 12 #include "ash/launcher/launcher.h" |
| 12 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
| 13 #include "ash/screen_ash.h" | 14 #include "ash/screen_ash.h" |
| 14 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 15 #include "ash/shell_delegate.h" | 16 #include "ash/shell_delegate.h" |
| 16 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
| 17 #include "ash/system/status_area_widget.h" | 18 #include "ash/system/status_area_widget.h" |
| 18 #include "ash/system/tray/system_tray.h" | 19 #include "ash/system/tray/system_tray.h" |
| 19 #include "ash/system/tray/system_tray_item.h" | 20 #include "ash/system/tray/system_tray_item.h" |
| 20 #include "ash/test/ash_test_base.h" | 21 #include "ash/test/ash_test_base.h" |
| 21 #include "ash/wm/window_util.h" | 22 #include "ash/wm/window_util.h" |
| 22 #include "base/command_line.h" | 23 #include "base/command_line.h" |
| 23 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
| 24 #include "ui/aura/client/aura_constants.h" | 25 #include "ui/aura/client/aura_constants.h" |
| 25 #include "ui/aura/env.h" | |
| 26 #include "ui/aura/display_manager.h" | |
| 27 #include "ui/aura/root_window.h" | 26 #include "ui/aura/root_window.h" |
| 28 #include "ui/aura/test/event_generator.h" | 27 #include "ui/aura/test/event_generator.h" |
| 29 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
| 30 #include "ui/base/animation/animation_container_element.h" | 29 #include "ui/base/animation/animation_container_element.h" |
| 31 #include "ui/compositor/layer.h" | 30 #include "ui/compositor/layer.h" |
| 32 #include "ui/compositor/layer_animator.h" | 31 #include "ui/compositor/layer_animator.h" |
| 33 #include "ui/gfx/display.h" | 32 #include "ui/gfx/display.h" |
| 34 #include "ui/gfx/screen.h" | 33 #include "ui/gfx/screen.h" |
| 35 #include "ui/views/controls/label.h" | 34 #include "ui/views/controls/label.h" |
| 36 #include "ui/views/layout/fill_layout.h" | 35 #include "ui/views/layout/fill_layout.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // Force an initial layout. | 196 // Force an initial layout. |
| 198 shelf->LayoutShelf(); | 197 shelf->LayoutShelf(); |
| 199 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 198 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
| 200 | 199 |
| 201 gfx::Rect status_bounds( | 200 gfx::Rect status_bounds( |
| 202 shelf->status_area_widget()->GetWindowBoundsInScreen()); | 201 shelf->status_area_widget()->GetWindowBoundsInScreen()); |
| 203 gfx::Rect launcher_bounds( | 202 gfx::Rect launcher_bounds( |
| 204 shelf->launcher_widget()->GetWindowBoundsInScreen()); | 203 shelf->launcher_widget()->GetWindowBoundsInScreen()); |
| 205 int shelf_height = shelf->GetIdealBounds().height(); | 204 int shelf_height = shelf->GetIdealBounds().height(); |
| 206 | 205 |
| 207 const aura::DisplayManager* manager = | 206 const gfx::Display& display = Shell::GetInstance()->display_manager()-> |
| 208 aura::Env::GetInstance()->display_manager(); | 207 GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 209 const gfx::Display& display = | |
| 210 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | |
| 211 ASSERT_NE(-1, display.id()); | 208 ASSERT_NE(-1, display.id()); |
| 212 // Bottom inset should be the max of widget heights. | 209 // Bottom inset should be the max of widget heights. |
| 213 EXPECT_EQ(shelf_height, | 210 EXPECT_EQ(shelf_height, |
| 214 display.bounds().bottom() - display.work_area().bottom()); | 211 display.bounds().bottom() - display.work_area().bottom()); |
| 215 | 212 |
| 216 // Hide the shelf. | 213 // Hide the shelf. |
| 217 SetState(shelf, ShelfLayoutManager::HIDDEN); | 214 SetState(shelf, ShelfLayoutManager::HIDDEN); |
| 218 // Run the animation to completion. | 215 // Run the animation to completion. |
| 219 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); | 216 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); |
| 220 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); | 217 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 249 bottom + shelf_height - status_bounds.height()); | 246 bottom + shelf_height - status_bounds.height()); |
| 250 } | 247 } |
| 251 | 248 |
| 252 // Makes sure LayoutShelf invoked while animating cleans things up. | 249 // Makes sure LayoutShelf invoked while animating cleans things up. |
| 253 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { | 250 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { |
| 254 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 251 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 255 // Force an initial layout. | 252 // Force an initial layout. |
| 256 shelf->LayoutShelf(); | 253 shelf->LayoutShelf(); |
| 257 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 254 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
| 258 | 255 |
| 259 const aura::DisplayManager* manager = | 256 const gfx::Display& display = Shell::GetInstance()->display_manager()-> |
| 260 aura::Env::GetInstance()->display_manager(); | 257 GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 261 const gfx::Display& display = | |
| 262 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | |
| 263 | 258 |
| 264 // Hide the shelf. | 259 // Hide the shelf. |
| 265 SetState(shelf, ShelfLayoutManager::HIDDEN); | 260 SetState(shelf, ShelfLayoutManager::HIDDEN); |
| 266 shelf->LayoutShelf(); | 261 shelf->LayoutShelf(); |
| 267 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 262 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); |
| 268 EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom()); | 263 EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom()); |
| 269 | 264 |
| 270 // Make sure the bounds of the two widgets changed. | 265 // Make sure the bounds of the two widgets changed. |
| 271 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), | 266 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), |
| 272 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); | 267 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 TEST_F(ShelfLayoutManagerTest, SetAlignment) { | 601 TEST_F(ShelfLayoutManagerTest, SetAlignment) { |
| 607 ShelfLayoutManager* shelf = shelf_layout_manager(); | 602 ShelfLayoutManager* shelf = shelf_layout_manager(); |
| 608 // Force an initial layout. | 603 // Force an initial layout. |
| 609 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 604 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 610 shelf->LayoutShelf(); | 605 shelf->LayoutShelf(); |
| 611 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 606 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
| 612 | 607 |
| 613 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 608 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 614 gfx::Rect launcher_bounds( | 609 gfx::Rect launcher_bounds( |
| 615 shelf->launcher_widget()->GetWindowBoundsInScreen()); | 610 shelf->launcher_widget()->GetWindowBoundsInScreen()); |
| 616 const aura::DisplayManager* manager = | 611 const internal::DisplayManager* manager = |
| 617 aura::Env::GetInstance()->display_manager(); | 612 Shell::GetInstance()->display_manager(); |
| 618 gfx::Display display = | 613 gfx::Display display = |
| 619 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 614 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 620 ASSERT_NE(-1, display.id()); | 615 ASSERT_NE(-1, display.id()); |
| 621 EXPECT_EQ(shelf->GetIdealBounds().width(), | 616 EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 622 display.GetWorkAreaInsets().left()); | 617 display.GetWorkAreaInsets().left()); |
| 623 EXPECT_GE( | 618 EXPECT_GE( |
| 624 launcher_bounds.width(), | 619 launcher_bounds.width(), |
| 625 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); | 620 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); |
| 626 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, | 621 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, |
| 627 Shell::GetInstance()->system_tray()->shelf_alignment()); | 622 Shell::GetInstance()->system_tray()->shelf_alignment()); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 972 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 978 } else { | 973 } else { |
| 979 EXPECT_FALSE(shelf->IsVisible()); | 974 EXPECT_FALSE(shelf->IsVisible()); |
| 980 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 975 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 981 } | 976 } |
| 982 } | 977 } |
| 983 } | 978 } |
| 984 | 979 |
| 985 } // namespace internal | 980 } // namespace internal |
| 986 } // namespace ash | 981 } // namespace ash |
| OLD | NEW |