| 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" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 gfx::Rect current_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 100 gfx::Rect current_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 101 int size = layout_manager->PrimaryAxisValue(current_bounds.height(), | 101 int size = layout_manager->PrimaryAxisValue(current_bounds.height(), |
| 102 current_bounds.width()); | 102 current_bounds.width()); |
| 103 int desired_size = layout_manager->PrimaryAxisValue(target_bounds_.height(), | 103 int desired_size = layout_manager->PrimaryAxisValue(target_bounds_.height(), |
| 104 target_bounds_.width()); | 104 target_bounds_.width()); |
| 105 return (size == desired_size); | 105 return (size == desired_size); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // views::WidgetObserver override. | 108 // views::WidgetObserver override. |
| 109 virtual void OnWidgetBoundsChanged(views::Widget* widget, | 109 virtual void OnWidgetBoundsChanged(views::Widget* widget, |
| 110 const gfx::Rect& new_bounds) OVERRIDE { | 110 const gfx::Rect& new_bounds) override { |
| 111 if (done_waiting_) | 111 if (done_waiting_) |
| 112 return; | 112 return; |
| 113 | 113 |
| 114 ++animation_steps_; | 114 ++animation_steps_; |
| 115 if (IsDoneAnimating()) { | 115 if (IsDoneAnimating()) { |
| 116 done_waiting_ = true; | 116 done_waiting_ = true; |
| 117 base::MessageLoop::current()->Quit(); | 117 base::MessageLoop::current()->Quit(); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 ShelfLayoutObserverTest() | 235 ShelfLayoutObserverTest() |
| 236 : changed_auto_hide_state_(false) { | 236 : changed_auto_hide_state_(false) { |
| 237 } | 237 } |
| 238 | 238 |
| 239 virtual ~ShelfLayoutObserverTest() {} | 239 virtual ~ShelfLayoutObserverTest() {} |
| 240 | 240 |
| 241 bool changed_auto_hide_state() const { return changed_auto_hide_state_; } | 241 bool changed_auto_hide_state() const { return changed_auto_hide_state_; } |
| 242 | 242 |
| 243 private: | 243 private: |
| 244 virtual void OnAutoHideStateChanged( | 244 virtual void OnAutoHideStateChanged( |
| 245 ShelfAutoHideState new_state) OVERRIDE { | 245 ShelfAutoHideState new_state) override { |
| 246 changed_auto_hide_state_ = true; | 246 changed_auto_hide_state_ = true; |
| 247 } | 247 } |
| 248 | 248 |
| 249 bool changed_auto_hide_state_; | 249 bool changed_auto_hide_state_; |
| 250 | 250 |
| 251 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutObserverTest); | 251 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutObserverTest); |
| 252 }; | 252 }; |
| 253 | 253 |
| 254 // Trivial item implementation that tracks its views for testing. | 254 // Trivial item implementation that tracks its views for testing. |
| 255 class TestItem : public SystemTrayItem { | 255 class TestItem : public SystemTrayItem { |
| 256 public: | 256 public: |
| 257 TestItem() | 257 TestItem() |
| 258 : SystemTrayItem(GetSystemTray()), | 258 : SystemTrayItem(GetSystemTray()), |
| 259 tray_view_(NULL), | 259 tray_view_(NULL), |
| 260 default_view_(NULL), | 260 default_view_(NULL), |
| 261 detailed_view_(NULL), | 261 detailed_view_(NULL), |
| 262 notification_view_(NULL) {} | 262 notification_view_(NULL) {} |
| 263 | 263 |
| 264 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE { | 264 virtual views::View* CreateTrayView(user::LoginStatus status) override { |
| 265 tray_view_ = new views::View; | 265 tray_view_ = new views::View; |
| 266 // Add a label so it has non-zero width. | 266 // Add a label so it has non-zero width. |
| 267 tray_view_->SetLayoutManager(new views::FillLayout); | 267 tray_view_->SetLayoutManager(new views::FillLayout); |
| 268 tray_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Tray"))); | 268 tray_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Tray"))); |
| 269 return tray_view_; | 269 return tray_view_; |
| 270 } | 270 } |
| 271 | 271 |
| 272 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE { | 272 virtual views::View* CreateDefaultView(user::LoginStatus status) override { |
| 273 default_view_ = new views::View; | 273 default_view_ = new views::View; |
| 274 default_view_->SetLayoutManager(new views::FillLayout); | 274 default_view_->SetLayoutManager(new views::FillLayout); |
| 275 default_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Default"))); | 275 default_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Default"))); |
| 276 return default_view_; | 276 return default_view_; |
| 277 } | 277 } |
| 278 | 278 |
| 279 virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE { | 279 virtual views::View* CreateDetailedView(user::LoginStatus status) override { |
| 280 detailed_view_ = new views::View; | 280 detailed_view_ = new views::View; |
| 281 detailed_view_->SetLayoutManager(new views::FillLayout); | 281 detailed_view_->SetLayoutManager(new views::FillLayout); |
| 282 detailed_view_->AddChildView( | 282 detailed_view_->AddChildView( |
| 283 new views::Label(base::UTF8ToUTF16("Detailed"))); | 283 new views::Label(base::UTF8ToUTF16("Detailed"))); |
| 284 return detailed_view_; | 284 return detailed_view_; |
| 285 } | 285 } |
| 286 | 286 |
| 287 virtual views::View* CreateNotificationView( | 287 virtual views::View* CreateNotificationView( |
| 288 user::LoginStatus status) OVERRIDE { | 288 user::LoginStatus status) override { |
| 289 notification_view_ = new views::View; | 289 notification_view_ = new views::View; |
| 290 return notification_view_; | 290 return notification_view_; |
| 291 } | 291 } |
| 292 | 292 |
| 293 virtual void DestroyTrayView() OVERRIDE { | 293 virtual void DestroyTrayView() override { |
| 294 tray_view_ = NULL; | 294 tray_view_ = NULL; |
| 295 } | 295 } |
| 296 | 296 |
| 297 virtual void DestroyDefaultView() OVERRIDE { | 297 virtual void DestroyDefaultView() override { |
| 298 default_view_ = NULL; | 298 default_view_ = NULL; |
| 299 } | 299 } |
| 300 | 300 |
| 301 virtual void DestroyDetailedView() OVERRIDE { | 301 virtual void DestroyDetailedView() override { |
| 302 detailed_view_ = NULL; | 302 detailed_view_ = NULL; |
| 303 } | 303 } |
| 304 | 304 |
| 305 virtual void DestroyNotificationView() OVERRIDE { | 305 virtual void DestroyNotificationView() override { |
| 306 notification_view_ = NULL; | 306 notification_view_ = NULL; |
| 307 } | 307 } |
| 308 | 308 |
| 309 virtual void UpdateAfterLoginStatusChange( | 309 virtual void UpdateAfterLoginStatusChange( |
| 310 user::LoginStatus status) OVERRIDE {} | 310 user::LoginStatus status) override {} |
| 311 | 311 |
| 312 views::View* tray_view() const { return tray_view_; } | 312 views::View* tray_view() const { return tray_view_; } |
| 313 views::View* default_view() const { return default_view_; } | 313 views::View* default_view() const { return default_view_; } |
| 314 views::View* detailed_view() const { return detailed_view_; } | 314 views::View* detailed_view() const { return detailed_view_; } |
| 315 views::View* notification_view() const { return notification_view_; } | 315 views::View* notification_view() const { return notification_view_; } |
| 316 | 316 |
| 317 private: | 317 private: |
| 318 views::View* tray_view_; | 318 views::View* tray_view_; |
| 319 views::View* default_view_; | 319 views::View* default_view_; |
| 320 views::View* detailed_view_; | 320 views::View* detailed_view_; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // Create a simple widget attached to the current context (will | 358 // Create a simple widget attached to the current context (will |
| 359 // delete on TearDown). | 359 // delete on TearDown). |
| 360 views::Widget* CreateTestWidget() { | 360 views::Widget* CreateTestWidget() { |
| 361 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 361 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 362 params.bounds = gfx::Rect(0, 0, 200, 200); | 362 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 363 params.context = CurrentContext(); | 363 params.context = CurrentContext(); |
| 364 return CreateTestWidgetWithParams(params); | 364 return CreateTestWidgetWithParams(params); |
| 365 } | 365 } |
| 366 | 366 |
| 367 // Overridden from AshTestBase: | 367 // Overridden from AshTestBase: |
| 368 virtual void SetUp() OVERRIDE { | 368 virtual void SetUp() override { |
| 369 CommandLine::ForCurrentProcess()->AppendSwitch( | 369 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 370 ash::switches::kAshEnableTrayDragging); | 370 ash::switches::kAshEnableTrayDragging); |
| 371 test::AshTestBase::SetUp(); | 371 test::AshTestBase::SetUp(); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void RunGestureDragTests(gfx::Vector2d); | 374 void RunGestureDragTests(gfx::Vector2d); |
| 375 | 375 |
| 376 private: | 376 private: |
| 377 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); | 377 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); |
| 378 }; | 378 }; |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2022 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 2022 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 2023 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); | 2023 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); |
| 2024 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); | 2024 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); |
| 2025 | 2025 |
| 2026 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 2026 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 2027 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); | 2027 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); |
| 2028 EXPECT_EQ(initial_bounds, reshow_target_bounds); | 2028 EXPECT_EQ(initial_bounds, reshow_target_bounds); |
| 2029 } | 2029 } |
| 2030 | 2030 |
| 2031 } // namespace ash | 2031 } // namespace ash |
| OLD | NEW |