| 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/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
| 14 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
| 15 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 16 #include "ui/aura/monitor.h" | 16 #include "ui/aura/monitor_aura.h" |
| 17 #include "ui/aura/monitor_manager.h" | 17 #include "ui/aura/monitor_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/gfx/compositor/layer_animator.h" | 22 #include "ui/gfx/compositor/layer_animator.h" |
| 23 #include "ui/gfx/compositor/layer.h" | 23 #include "ui/gfx/compositor/layer.h" |
| 24 #include "ui/gfx/screen.h" | 24 #include "ui/gfx/screen.h" |
| 25 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
| 26 | 26 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #define MAYBE_SetVisible SetVisible | 79 #define MAYBE_SetVisible SetVisible |
| 80 #endif | 80 #endif |
| 81 // Makes sure SetVisible updates work area and widget appropriately. | 81 // Makes sure SetVisible updates work area and widget appropriately. |
| 82 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { | 82 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { |
| 83 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 83 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 84 // Force an initial layout. | 84 // Force an initial layout. |
| 85 shelf->LayoutShelf(); | 85 shelf->LayoutShelf(); |
| 86 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 86 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
| 87 const aura::MonitorManager* manager = | 87 const aura::MonitorManager* manager = |
| 88 aura::Env::GetInstance()->monitor_manager(); | 88 aura::Env::GetInstance()->monitor_manager(); |
| 89 const aura::Monitor* monitor = | 89 const aura::MonitorAura* monitor = |
| 90 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); | 90 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); |
| 91 ASSERT_TRUE(monitor); | 91 ASSERT_TRUE(monitor); |
| 92 // Bottom inset should be the max of widget heights. | 92 // Bottom inset should be the max of widget heights. |
| 93 EXPECT_EQ(shelf->shelf_height(), | 93 EXPECT_EQ(shelf->shelf_height(), |
| 94 monitor->work_area_insets().bottom()); | 94 monitor->work_area_insets().bottom()); |
| 95 | 95 |
| 96 // Hide the shelf. | 96 // Hide the shelf. |
| 97 SetState(shelf, ShelfLayoutManager::HIDDEN); | 97 SetState(shelf, ShelfLayoutManager::HIDDEN); |
| 98 // Run the animation to completion. | 98 // Run the animation to completion. |
| 99 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); | 99 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 130 | 130 |
| 131 // Makes sure LayoutShelf invoked while animating cleans things up. | 131 // Makes sure LayoutShelf invoked while animating cleans things up. |
| 132 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { | 132 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { |
| 133 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 133 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 134 // Force an initial layout. | 134 // Force an initial layout. |
| 135 shelf->LayoutShelf(); | 135 shelf->LayoutShelf(); |
| 136 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 136 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
| 137 | 137 |
| 138 const aura::MonitorManager* manager = | 138 const aura::MonitorManager* manager = |
| 139 aura::Env::GetInstance()->monitor_manager(); | 139 aura::Env::GetInstance()->monitor_manager(); |
| 140 const aura::Monitor* monitor = | 140 const aura::MonitorAura* monitor = |
| 141 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); | 141 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); |
| 142 | 142 |
| 143 // Hide the shelf. | 143 // Hide the shelf. |
| 144 SetState(shelf, ShelfLayoutManager::HIDDEN); | 144 SetState(shelf, ShelfLayoutManager::HIDDEN); |
| 145 shelf->LayoutShelf(); | 145 shelf->LayoutShelf(); |
| 146 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 146 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); |
| 147 EXPECT_EQ(0, monitor->work_area_insets().bottom()); | 147 EXPECT_EQ(0, monitor->work_area_insets().bottom()); |
| 148 // Make sure the bounds of the two widgets changed. | 148 // Make sure the bounds of the two widgets changed. |
| 149 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), | 149 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), |
| 150 gfx::Screen::GetPrimaryMonitorBounds().bottom()); | 150 gfx::Screen::GetPrimaryMonitorBounds().bottom()); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 471 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); |
| 472 | 472 |
| 473 // Toggle app list to hide. | 473 // Toggle app list to hide. |
| 474 shell->ToggleAppList(); | 474 shell->ToggleAppList(); |
| 475 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 475 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 476 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 476 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); |
| 477 } | 477 } |
| 478 | 478 |
| 479 } // namespace internal | 479 } // namespace internal |
| 480 } // namespace ash | 480 } // namespace ash |
| OLD | NEW |