| 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/test/shelf_view_test_api.h" | 5 #include "ash/test/shelf_view_test_api.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_constants.h" | 7 #include "ash/common/shelf/shelf_constants.h" |
| 8 #include "ash/common/shelf/shelf_model.h" | 8 #include "ash/common/shelf/shelf_model.h" |
| 9 #include "ash/shelf/overflow_button.h" | 9 #include "ash/shelf/overflow_button.h" |
| 10 #include "ash/shelf/shelf_button.h" | 10 #include "ash/shelf/shelf_button.h" |
| 11 #include "ash/shelf/shelf_view.h" | 11 #include "ash/shelf/shelf_view.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "ui/views/animation/bounds_animator.h" | 13 #include "ui/views/animation/bounds_animator.h" |
| 14 #include "ui/views/controls/menu/menu_runner.h" |
| 14 #include "ui/views/view_model.h" | 15 #include "ui/views/view_model.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // A class used to wait for animations. | 19 // A class used to wait for animations. |
| 19 class TestAPIAnimationObserver : public views::BoundsAnimatorObserver { | 20 class TestAPIAnimationObserver : public views::BoundsAnimatorObserver { |
| 20 public: | 21 public: |
| 21 TestAPIAnimationObserver() {} | 22 TestAPIAnimationObserver() {} |
| 22 ~TestAPIAnimationObserver() override {} | 23 ~TestAPIAnimationObserver() override {} |
| 23 | 24 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 new TestAPIAnimationObserver()); | 92 new TestAPIAnimationObserver()); |
| 92 shelf_view_->bounds_animator_->AddObserver(observer.get()); | 93 shelf_view_->bounds_animator_->AddObserver(observer.get()); |
| 93 | 94 |
| 94 // This nested loop will quit when TestAPIAnimationObserver's | 95 // This nested loop will quit when TestAPIAnimationObserver's |
| 95 // OnBoundsAnimatorDone is called. | 96 // OnBoundsAnimatorDone is called. |
| 96 base::MessageLoop::current()->Run(); | 97 base::MessageLoop::current()->Run(); |
| 97 | 98 |
| 98 shelf_view_->bounds_animator_->RemoveObserver(observer.get()); | 99 shelf_view_->bounds_animator_->RemoveObserver(observer.get()); |
| 99 } | 100 } |
| 100 | 101 |
| 102 void ShelfViewTestAPI::CloseMenu() { |
| 103 if (!shelf_view_->launcher_menu_runner_) |
| 104 return; |
| 105 |
| 106 shelf_view_->launcher_menu_runner_->Cancel(); |
| 107 } |
| 108 |
| 101 OverflowBubble* ShelfViewTestAPI::overflow_bubble() { | 109 OverflowBubble* ShelfViewTestAPI::overflow_bubble() { |
| 102 return shelf_view_->overflow_bubble_.get(); | 110 return shelf_view_->overflow_bubble_.get(); |
| 103 } | 111 } |
| 104 | 112 |
| 105 ShelfTooltipManager* ShelfViewTestAPI::tooltip_manager() { | 113 ShelfTooltipManager* ShelfViewTestAPI::tooltip_manager() { |
| 106 return &shelf_view_->tooltip_; | 114 return &shelf_view_->tooltip_; |
| 107 } | 115 } |
| 108 | 116 |
| 109 gfx::Size ShelfViewTestAPI::GetPreferredSize() { | 117 gfx::Size ShelfViewTestAPI::GetPreferredSize() { |
| 110 return shelf_view_->GetPreferredSize(); | 118 return shelf_view_->GetPreferredSize(); |
| 111 } | 119 } |
| 112 | 120 |
| 113 int ShelfViewTestAPI::GetButtonSize() { | 121 int ShelfViewTestAPI::GetButtonSize() { |
| 114 return GetShelfConstant(SHELF_BUTTON_SIZE); | 122 return GetShelfConstant(SHELF_BUTTON_SIZE); |
| 115 } | 123 } |
| 116 | 124 |
| 117 int ShelfViewTestAPI::GetButtonSpacing() { | 125 int ShelfViewTestAPI::GetButtonSpacing() { |
| 118 return GetShelfConstant(SHELF_BUTTON_SPACING); | 126 return GetShelfConstant(SHELF_BUTTON_SPACING); |
| 119 } | 127 } |
| 120 | 128 |
| 129 int ShelfViewTestAPI::GetMinimumDragDistance() const { |
| 130 return ShelfView::kMinimumDragDistance; |
| 131 } |
| 132 |
| 121 void ShelfViewTestAPI::ButtonPressed(views::Button* sender, | 133 void ShelfViewTestAPI::ButtonPressed(views::Button* sender, |
| 122 const ui::Event& event) { | 134 const ui::Event& event, |
| 123 return shelf_view_->ButtonPressed(sender, event); | 135 views::InkDrop* ink_drop) { |
| 136 return shelf_view_->ButtonPressed(sender, event, ink_drop); |
| 124 } | 137 } |
| 125 | 138 |
| 126 bool ShelfViewTestAPI::SameDragType(ShelfItemType typea, | 139 bool ShelfViewTestAPI::SameDragType(ShelfItemType typea, |
| 127 ShelfItemType typeb) const { | 140 ShelfItemType typeb) const { |
| 128 return shelf_view_->SameDragType(typea, typeb); | 141 return shelf_view_->SameDragType(typea, typeb); |
| 129 } | 142 } |
| 130 | 143 |
| 131 void ShelfViewTestAPI::SetShelfDelegate(ShelfDelegate* delegate) { | 144 void ShelfViewTestAPI::SetShelfDelegate(ShelfDelegate* delegate) { |
| 132 shelf_view_->delegate_ = delegate; | 145 shelf_view_->delegate_ = delegate; |
| 133 } | 146 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 144 return shelf_view_->dragged_off_from_overflow_to_shelf_; | 157 return shelf_view_->dragged_off_from_overflow_to_shelf_; |
| 145 } | 158 } |
| 146 | 159 |
| 147 ShelfButtonPressedMetricTracker* | 160 ShelfButtonPressedMetricTracker* |
| 148 ShelfViewTestAPI::shelf_button_pressed_metric_tracker() { | 161 ShelfViewTestAPI::shelf_button_pressed_metric_tracker() { |
| 149 return &(shelf_view_->shelf_button_pressed_metric_tracker_); | 162 return &(shelf_view_->shelf_button_pressed_metric_tracker_); |
| 150 } | 163 } |
| 151 | 164 |
| 152 } // namespace test | 165 } // namespace test |
| 153 } // namespace ash | 166 } // namespace ash |
| OLD | NEW |