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/overflow_button.h" | 7 #include "ash/common/shelf/overflow_button.h" |
8 #include "ash/common/shelf/shelf_button.h" | 8 #include "ash/common/shelf/shelf_button.h" |
9 #include "ash/common/shelf/shelf_constants.h" | 9 #include "ash/common/shelf/shelf_constants.h" |
10 #include "ash/common/shelf/shelf_model.h" | 10 #include "ash/common/shelf/shelf_model.h" |
11 #include "ash/common/shelf/shelf_view.h" | 11 #include "ash/common/shelf/shelf_view.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" |
13 #include "ui/views/animation/bounds_animator.h" | 14 #include "ui/views/animation/bounds_animator.h" |
14 #include "ui/views/controls/menu/menu_runner.h" | 15 #include "ui/views/controls/menu/menu_runner.h" |
15 #include "ui/views/view_model.h" | 16 #include "ui/views/view_model.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 // A class used to wait for animations. | 20 // A class used to wait for animations. |
20 class TestAPIAnimationObserver : public views::BoundsAnimatorObserver { | 21 class TestAPIAnimationObserver : public views::BoundsAnimatorObserver { |
21 public: | 22 public: |
22 TestAPIAnimationObserver() {} | 23 TestAPIAnimationObserver() {} |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 void ShelfViewTestAPI::RunMessageLoopUntilAnimationsDone() { | 87 void ShelfViewTestAPI::RunMessageLoopUntilAnimationsDone() { |
87 if (!shelf_view_->bounds_animator_->IsAnimating()) | 88 if (!shelf_view_->bounds_animator_->IsAnimating()) |
88 return; | 89 return; |
89 | 90 |
90 std::unique_ptr<TestAPIAnimationObserver> observer( | 91 std::unique_ptr<TestAPIAnimationObserver> observer( |
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::RunLoop().Run(); |
97 | 98 |
98 shelf_view_->bounds_animator_->RemoveObserver(observer.get()); | 99 shelf_view_->bounds_animator_->RemoveObserver(observer.get()); |
99 } | 100 } |
100 | 101 |
101 void ShelfViewTestAPI::CloseMenu() { | 102 void ShelfViewTestAPI::CloseMenu() { |
102 if (!shelf_view_->launcher_menu_runner_) | 103 if (!shelf_view_->launcher_menu_runner_) |
103 return; | 104 return; |
104 | 105 |
105 shelf_view_->launcher_menu_runner_->Cancel(); | 106 shelf_view_->launcher_menu_runner_->Cancel(); |
106 } | 107 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 return shelf_view_->dragged_off_from_overflow_to_shelf_; | 157 return shelf_view_->dragged_off_from_overflow_to_shelf_; |
157 } | 158 } |
158 | 159 |
159 ShelfButtonPressedMetricTracker* | 160 ShelfButtonPressedMetricTracker* |
160 ShelfViewTestAPI::shelf_button_pressed_metric_tracker() { | 161 ShelfViewTestAPI::shelf_button_pressed_metric_tracker() { |
161 return &(shelf_view_->shelf_button_pressed_metric_tracker_); | 162 return &(shelf_view_->shelf_button_pressed_metric_tracker_); |
162 } | 163 } |
163 | 164 |
164 } // namespace test | 165 } // namespace test |
165 } // namespace ash | 166 } // namespace ash |
OLD | NEW |