| 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/focus_cycler.h" | 10 #include "ash/focus_cycler.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 SetState(shelf, ShelfLayoutManager::HIDDEN); | 211 SetState(shelf, ShelfLayoutManager::HIDDEN); |
| 212 // Run the animation to completion. | 212 // Run the animation to completion. |
| 213 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); | 213 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); |
| 214 StepWidgetLayerAnimatorToEnd(shelf->status()); | 214 StepWidgetLayerAnimatorToEnd(shelf->status()); |
| 215 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 215 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); |
| 216 EXPECT_EQ(0, | 216 EXPECT_EQ(0, |
| 217 display.bounds().bottom() - display.work_area().bottom()); | 217 display.bounds().bottom() - display.work_area().bottom()); |
| 218 | 218 |
| 219 // Make sure the bounds of the two widgets changed. | 219 // Make sure the bounds of the two widgets changed. |
| 220 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), | 220 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), |
| 221 gfx::Screen::GetPrimaryDisplay().bounds().bottom()); | 221 gfx::Screen::GetPrimaryDisplay( |
| 222 ash::Shell::GetRootNativeView()).bounds().bottom()); |
| 222 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), | 223 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), |
| 223 gfx::Screen::GetPrimaryDisplay().bounds().bottom()); | 224 gfx::Screen::GetPrimaryDisplay( |
| 225 ash::Shell::GetRootNativeView()).bounds().bottom()); |
| 224 | 226 |
| 225 // And show it again. | 227 // And show it again. |
| 226 SetState(shelf, ShelfLayoutManager::VISIBLE); | 228 SetState(shelf, ShelfLayoutManager::VISIBLE); |
| 227 // Run the animation to completion. | 229 // Run the animation to completion. |
| 228 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); | 230 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); |
| 229 StepWidgetLayerAnimatorToEnd(shelf->status()); | 231 StepWidgetLayerAnimatorToEnd(shelf->status()); |
| 230 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 232 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
| 231 EXPECT_EQ(shelf_height, | 233 EXPECT_EQ(shelf_height, |
| 232 display.bounds().bottom() - display.work_area().bottom()); | 234 display.bounds().bottom() - display.work_area().bottom()); |
| 233 | 235 |
| 234 // Make sure the bounds of the two widgets changed. | 236 // Make sure the bounds of the two widgets changed. |
| 235 launcher_bounds = shelf->launcher_widget()->GetNativeView()->bounds(); | 237 launcher_bounds = shelf->launcher_widget()->GetNativeView()->bounds(); |
| 236 int bottom = gfx::Screen::GetPrimaryDisplay().bounds().bottom() - | 238 int bottom = gfx::Screen::GetPrimaryDisplay( |
| 237 shelf_height; | 239 ash::Shell::GetRootNativeView()).bounds().bottom() - shelf_height; |
| 238 EXPECT_EQ(launcher_bounds.y(), | 240 EXPECT_EQ(launcher_bounds.y(), |
| 239 bottom + (shelf->GetIdealBounds().height() - | 241 bottom + (shelf->GetIdealBounds().height() - |
| 240 launcher_bounds.height()) / 2); | 242 launcher_bounds.height()) / 2); |
| 241 status_bounds = shelf->status()->GetNativeView()->bounds(); | 243 status_bounds = shelf->status()->GetNativeView()->bounds(); |
| 242 EXPECT_EQ(status_bounds.y(), | 244 EXPECT_EQ(status_bounds.y(), |
| 243 bottom + shelf_height - status_bounds.height()); | 245 bottom + shelf_height - status_bounds.height()); |
| 244 } | 246 } |
| 245 | 247 |
| 246 // Makes sure LayoutShelf invoked while animating cleans things up. | 248 // Makes sure LayoutShelf invoked while animating cleans things up. |
| 247 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { | 249 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { |
| 248 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 250 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 249 // Force an initial layout. | 251 // Force an initial layout. |
| 250 shelf->LayoutShelf(); | 252 shelf->LayoutShelf(); |
| 251 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 253 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
| 252 | 254 |
| 253 const aura::DisplayManager* manager = | 255 const aura::DisplayManager* manager = |
| 254 aura::Env::GetInstance()->display_manager(); | 256 aura::Env::GetInstance()->display_manager(); |
| 255 const gfx::Display& display = | 257 const gfx::Display& display = |
| 256 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 258 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 257 | 259 |
| 258 // Hide the shelf. | 260 // Hide the shelf. |
| 259 SetState(shelf, ShelfLayoutManager::HIDDEN); | 261 SetState(shelf, ShelfLayoutManager::HIDDEN); |
| 260 shelf->LayoutShelf(); | 262 shelf->LayoutShelf(); |
| 261 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 263 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); |
| 262 EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom()); | 264 EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom()); |
| 263 | 265 |
| 264 // Make sure the bounds of the two widgets changed. | 266 // Make sure the bounds of the two widgets changed. |
| 265 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), | 267 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), |
| 266 gfx::Screen::GetPrimaryDisplay().bounds().bottom()); | 268 gfx::Screen::GetPrimaryDisplay( |
| 269 ash::Shell::GetRootNativeView()).bounds().bottom()); |
| 267 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), | 270 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), |
| 268 gfx::Screen::GetPrimaryDisplay().bounds().bottom()); | 271 gfx::Screen::GetPrimaryDisplay( |
| 272 ash::Shell::GetRootNativeView()).bounds().bottom()); |
| 269 } | 273 } |
| 270 | 274 |
| 271 // Makes sure the launcher is initially sized correctly. | 275 // Makes sure the launcher is initially sized correctly. |
| 272 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) { | 276 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) { |
| 273 Launcher* launcher = Shell::GetInstance()->launcher(); | 277 Launcher* launcher = Shell::GetInstance()->launcher(); |
| 274 ASSERT_TRUE(launcher); | 278 ASSERT_TRUE(launcher); |
| 275 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); | 279 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); |
| 276 ASSERT_TRUE(shelf_layout_manager); | 280 ASSERT_TRUE(shelf_layout_manager); |
| 277 ASSERT_TRUE(shelf_layout_manager->status()); | 281 ASSERT_TRUE(shelf_layout_manager->status()); |
| 278 int status_width = | 282 int status_width = |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 EXPECT_TRUE(status_area->IsMessageBubbleShown()); | 953 EXPECT_TRUE(status_area->IsMessageBubbleShown()); |
| 950 } else { | 954 } else { |
| 951 EXPECT_FALSE(shelf->IsVisible()); | 955 EXPECT_FALSE(shelf->IsVisible()); |
| 952 EXPECT_FALSE(status_area->IsMessageBubbleShown()); | 956 EXPECT_FALSE(status_area->IsMessageBubbleShown()); |
| 953 } | 957 } |
| 954 } | 958 } |
| 955 } | 959 } |
| 956 | 960 |
| 957 } // namespace internal | 961 } // namespace internal |
| 958 } // namespace ash | 962 } // namespace ash |
| OLD | NEW |