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/focus_cycler.h" | 7 #include "ash/focus_cycler.h" |
8 #include "ash/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/shell_delegate.h" | 11 #include "ash/shell_delegate.h" |
12 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
13 #include "ash/system/tray/system_tray.h" | 13 #include "ash/system/tray/system_tray.h" |
14 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
15 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
16 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
17 #include "ui/aura/monitor_manager.h" | 17 #include "ui/aura/display_manager.h" |
18 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
19 #include "ui/aura/test/event_generator.h" | 19 #include "ui/aura/test/event_generator.h" |
20 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
21 #include "ui/base/animation/animation_container_element.h" | 21 #include "ui/base/animation/animation_container_element.h" |
22 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
23 #include "ui/compositor/layer_animator.h" | 23 #include "ui/compositor/layer_animator.h" |
24 #include "ui/gfx/display.h" | 24 #include "ui/gfx/display.h" |
25 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
26 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
27 | 27 |
(...skipping 57 matching lines...) Loading... |
85 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { | 85 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { |
86 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 86 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
87 // Force an initial layout. | 87 // Force an initial layout. |
88 shelf->LayoutShelf(); | 88 shelf->LayoutShelf(); |
89 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 89 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
90 | 90 |
91 gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds()); | 91 gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds()); |
92 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds()); | 92 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds()); |
93 int shelf_height = shelf->GetIdealBounds().height(); | 93 int shelf_height = shelf->GetIdealBounds().height(); |
94 | 94 |
95 const aura::MonitorManager* manager = | 95 const aura::DisplayManager* manager = |
96 aura::Env::GetInstance()->monitor_manager(); | 96 aura::Env::GetInstance()->display_manager(); |
97 const gfx::Display& display = | 97 const gfx::Display& display = |
98 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 98 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
99 ASSERT_NE(-1, display.id()); | 99 ASSERT_NE(-1, display.id()); |
100 // Bottom inset should be the max of widget heights. | 100 // Bottom inset should be the max of widget heights. |
101 EXPECT_EQ(shelf_height, | 101 EXPECT_EQ(shelf_height, |
102 display.bounds().bottom() - display.work_area().bottom()); | 102 display.bounds().bottom() - display.work_area().bottom()); |
103 | 103 |
104 // Hide the shelf. | 104 // Hide the shelf. |
105 SetState(shelf, ShelfLayoutManager::HIDDEN); | 105 SetState(shelf, ShelfLayoutManager::HIDDEN); |
106 // Run the animation to completion. | 106 // Run the animation to completion. |
(...skipping 30 matching lines...) Loading... |
137 bottom + shelf_height - status_bounds.height()); | 137 bottom + shelf_height - status_bounds.height()); |
138 } | 138 } |
139 | 139 |
140 // Makes sure LayoutShelf invoked while animating cleans things up. | 140 // Makes sure LayoutShelf invoked while animating cleans things up. |
141 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { | 141 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { |
142 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 142 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
143 // Force an initial layout. | 143 // Force an initial layout. |
144 shelf->LayoutShelf(); | 144 shelf->LayoutShelf(); |
145 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 145 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
146 | 146 |
147 const aura::MonitorManager* manager = | 147 const aura::DisplayManager* manager = |
148 aura::Env::GetInstance()->monitor_manager(); | 148 aura::Env::GetInstance()->display_manager(); |
149 const gfx::Display& display = | 149 const gfx::Display& display = |
150 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 150 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
151 | 151 |
152 // Hide the shelf. | 152 // Hide the shelf. |
153 SetState(shelf, ShelfLayoutManager::HIDDEN); | 153 SetState(shelf, ShelfLayoutManager::HIDDEN); |
154 shelf->LayoutShelf(); | 154 shelf->LayoutShelf(); |
155 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 155 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); |
156 EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom()); | 156 EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom()); |
157 | 157 |
158 // Make sure the bounds of the two widgets changed. | 158 // Make sure the bounds of the two widgets changed. |
(...skipping 160 matching lines...) Loading... |
319 generator.MoveMouseTo(0, 0); | 319 generator.MoveMouseTo(0, 0); |
320 | 320 |
321 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 321 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
322 views::Widget* widget = new views::Widget; | 322 views::Widget* widget = new views::Widget; |
323 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 323 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
324 params.bounds = gfx::Rect(0, 0, 200, 200); | 324 params.bounds = gfx::Rect(0, 0, 200, 200); |
325 // Widget is now owned by the parent window. | 325 // Widget is now owned by the parent window. |
326 widget->Init(params); | 326 widget->Init(params); |
327 widget->Show(); | 327 widget->Show(); |
328 aura::Window* window = widget->GetNativeWindow(); | 328 aura::Window* window = widget->GetNativeWindow(); |
329 gfx::Rect monitor_bounds( | 329 gfx::Rect display_bounds( |
330 gfx::Screen::GetDisplayNearestWindow(window).bounds()); | 330 gfx::Screen::GetDisplayNearestWindow(window).bounds()); |
331 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, | 331 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, |
332 shelf->GetMaximizedWindowBounds(window).bottom()); | 332 shelf->GetMaximizedWindowBounds(window).bottom()); |
333 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 333 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
334 | 334 |
335 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 335 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
336 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 336 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
337 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, | 337 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, |
338 shelf->GetMaximizedWindowBounds(window).bottom()); | 338 shelf->GetMaximizedWindowBounds(window).bottom()); |
339 | 339 |
340 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT); | 340 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT); |
341 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 341 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
342 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, | 342 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, |
343 shelf->GetMaximizedWindowBounds(window).bottom()); | 343 shelf->GetMaximizedWindowBounds(window).bottom()); |
344 | 344 |
345 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 345 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
346 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 346 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
347 EXPECT_GT(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, | 347 EXPECT_GT(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, |
348 shelf->GetMaximizedWindowBounds(window).bottom()); | 348 shelf->GetMaximizedWindowBounds(window).bottom()); |
349 | 349 |
350 widget->Maximize(); | 350 widget->Maximize(); |
351 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 351 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
352 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), | 352 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), |
353 widget->GetWorkAreaBoundsInScreen().bottom()); | 353 widget->GetWorkAreaBoundsInScreen().bottom()); |
354 | 354 |
355 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 355 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
356 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 356 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
357 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), | 357 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), |
(...skipping 133 matching lines...) Loading... |
491 // Tests SHELF_ALIGNMENT_LEFT and SHELF_ALIGNMENT_RIGHT. | 491 // Tests SHELF_ALIGNMENT_LEFT and SHELF_ALIGNMENT_RIGHT. |
492 TEST_F(ShelfLayoutManagerTest, SetAlignment) { | 492 TEST_F(ShelfLayoutManagerTest, SetAlignment) { |
493 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 493 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
494 // Force an initial layout. | 494 // Force an initial layout. |
495 shelf->LayoutShelf(); | 495 shelf->LayoutShelf(); |
496 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 496 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
497 | 497 |
498 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 498 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
499 | 499 |
500 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds()); | 500 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds()); |
501 const aura::MonitorManager* manager = | 501 const aura::DisplayManager* manager = |
502 aura::Env::GetInstance()->monitor_manager(); | 502 aura::Env::GetInstance()->display_manager(); |
503 gfx::Display display = | 503 gfx::Display display = |
504 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 504 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
505 ASSERT_NE(-1, display.id()); | 505 ASSERT_NE(-1, display.id()); |
506 EXPECT_EQ(shelf->GetIdealBounds().width(), | 506 EXPECT_EQ(shelf->GetIdealBounds().width(), |
507 display.GetWorkAreaInsets().left()); | 507 display.GetWorkAreaInsets().left()); |
508 EXPECT_GE( | 508 EXPECT_GE( |
509 launcher_bounds.width(), | 509 launcher_bounds.width(), |
510 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); | 510 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); |
511 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, | 511 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, |
512 Shell::GetInstance()->system_tray()->shelf_alignment()); | 512 Shell::GetInstance()->system_tray()->shelf_alignment()); |
(...skipping 28 matching lines...) Loading... |
541 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); | 541 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
542 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 542 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
543 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); | 543 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); |
544 EXPECT_EQ(display.work_area().right(), launcher_bounds.x()); | 544 EXPECT_EQ(display.work_area().right(), launcher_bounds.x()); |
545 EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); | 545 EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); |
546 EXPECT_EQ(display.bounds().height(), launcher_bounds.height()); | 546 EXPECT_EQ(display.bounds().height(), launcher_bounds.height()); |
547 } | 547 } |
548 | 548 |
549 } // namespace internal | 549 } // namespace internal |
550 } // namespace ash | 550 } // namespace ash |
OLD | NEW |