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/launcher_view_test_api.h" | 5 #include "ash/test/launcher_view_test_api.h" |
6 | 6 |
7 #include "ash/launcher/app_list_button.h" | |
7 #include "ash/launcher/launcher_button.h" | 8 #include "ash/launcher/launcher_button.h" |
8 #include "ash/launcher/launcher_model.h" | 9 #include "ash/launcher/launcher_model.h" |
9 #include "ash/launcher/launcher_view.h" | 10 #include "ash/launcher/launcher_view.h" |
10 #include "ash/launcher/overflow_button.h" | 11 #include "ash/launcher/overflow_button.h" |
11 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
12 #include "ui/views/animation/bounds_animator.h" | 13 #include "ui/views/animation/bounds_animator.h" |
13 #include "ui/views/view_model.h" | 14 #include "ui/views/view_model.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 } | 71 } |
71 | 72 |
72 const gfx::Rect& LauncherViewTestAPI::GetBoundsByIndex(int index) { | 73 const gfx::Rect& LauncherViewTestAPI::GetBoundsByIndex(int index) { |
73 return launcher_view_->view_model_->view_at(index)->bounds(); | 74 return launcher_view_->view_model_->view_at(index)->bounds(); |
74 } | 75 } |
75 | 76 |
76 const gfx::Rect& LauncherViewTestAPI::GetIdealBoundsByIndex(int index) { | 77 const gfx::Rect& LauncherViewTestAPI::GetIdealBoundsByIndex(int index) { |
77 return launcher_view_->view_model_->ideal_bounds(index); | 78 return launcher_view_->view_model_->ideal_bounds(index); |
78 } | 79 } |
79 | 80 |
81 internal::AppListButton* LauncherViewTestAPI::GetAppListButton() { | |
82 DCHECK_EQ(launcher_view_->model_->item_count(), | |
83 launcher_view_->view_model_->view_size()); | |
84 | |
85 for (int i = 0; i < launcher_view_->model_->item_count(); ++i) { | |
86 if (launcher_view_->model_->items()[i].type == ash::TYPE_APP_LIST) { | |
sky
2013/04/29 20:40:55
Isn't this the same as LauncherView::GetAppListBut
xiyuan
2013/04/29 21:12:45
You are absolutely right. I totally forgot that fu
| |
87 return static_cast<internal::AppListButton*>( | |
88 launcher_view_->view_model_->view_at(i)); | |
89 } | |
90 } | |
91 | |
92 return NULL; | |
93 } | |
94 | |
80 void LauncherViewTestAPI::SetAnimationDuration(int duration_ms) { | 95 void LauncherViewTestAPI::SetAnimationDuration(int duration_ms) { |
81 launcher_view_->bounds_animator_->SetAnimationDuration(duration_ms); | 96 launcher_view_->bounds_animator_->SetAnimationDuration(duration_ms); |
82 } | 97 } |
83 | 98 |
84 void LauncherViewTestAPI::RunMessageLoopUntilAnimationsDone() { | 99 void LauncherViewTestAPI::RunMessageLoopUntilAnimationsDone() { |
85 if (!launcher_view_->bounds_animator_->IsAnimating()) | 100 if (!launcher_view_->bounds_animator_->IsAnimating()) |
86 return; | 101 return; |
87 | 102 |
88 scoped_ptr<TestAPIAnimationObserver> observer(new TestAPIAnimationObserver()); | 103 scoped_ptr<TestAPIAnimationObserver> observer(new TestAPIAnimationObserver()); |
89 launcher_view_->bounds_animator_->AddObserver(observer.get()); | 104 launcher_view_->bounds_animator_->AddObserver(observer.get()); |
90 | 105 |
91 // This nested loop will quit when TestAPIAnimationObserver's | 106 // This nested loop will quit when TestAPIAnimationObserver's |
92 // OnBoundsAnimatorDone is called. | 107 // OnBoundsAnimatorDone is called. |
93 MessageLoop::current()->Run(); | 108 MessageLoop::current()->Run(); |
94 | 109 |
95 launcher_view_->bounds_animator_->RemoveObserver(observer.get()); | 110 launcher_view_->bounds_animator_->RemoveObserver(observer.get()); |
96 } | 111 } |
97 | 112 |
98 } // namespace test | 113 } // namespace test |
99 } // namespace ash | 114 } // namespace ash |
OLD | NEW |