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 "chrome/test/base/view_event_test_base.h" | 5 #include "chrome/test/base/view_event_test_base.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "chrome/test/base/interactive_test_utils.h" | 11 #include "chrome/test/base/interactive_test_utils.h" |
12 #include "chrome/test/base/ui_controls.h" | 12 #include "chrome/test/base/ui_controls.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "ui/base/ime/text_input_test_support.h" | 15 #include "ui/base/ime/text_input_test_support.h" |
16 #include "ui/compositor/test/compositor_test_support.h" | |
17 #include "ui/message_center/message_center.h" | 16 #include "ui/message_center/message_center.h" |
18 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
19 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 18 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
20 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
21 | 20 |
22 #if defined(USE_ASH) | 21 #if defined(USE_ASH) |
23 #include "ash/shell.h" | 22 #include "ash/shell.h" |
24 #include "ash/test/test_shell_delegate.h" | 23 #include "ash/test/test_shell_delegate.h" |
25 #endif | 24 #endif |
26 | 25 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // If we're in a nested message loop, as is the case with menus, we | 93 // If we're in a nested message loop, as is the case with menus, we |
95 // need to quit twice. The second quit does that for us. Finish all | 94 // need to quit twice. The second quit does that for us. Finish all |
96 // pending UI events before posting closure because events it may be | 95 // pending UI events before posting closure because events it may be |
97 // executed before UI events are executed. | 96 // executed before UI events are executed. |
98 ui_controls::RunClosureAfterAllPendingUIEvents( | 97 ui_controls::RunClosureAfterAllPendingUIEvents( |
99 base::MessageLoop::QuitClosure()); | 98 base::MessageLoop::QuitClosure()); |
100 } | 99 } |
101 | 100 |
102 void ViewEventTestBase::SetUp() { | 101 void ViewEventTestBase::SetUp() { |
103 ui::TextInputTestSupport::Initialize(); | 102 ui::TextInputTestSupport::Initialize(); |
104 ui::CompositorTestSupport::Initialize(); | |
105 gfx::NativeView context = NULL; | 103 gfx::NativeView context = NULL; |
106 #if defined(USE_ASH) | 104 #if defined(USE_ASH) |
107 #if defined(OS_WIN) | 105 #if defined(OS_WIN) |
108 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when | 106 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when |
109 // interactive_ui_tests is brought up on that platform. | 107 // interactive_ui_tests is brought up on that platform. |
110 gfx::Screen::SetScreenInstance( | 108 gfx::Screen::SetScreenInstance( |
111 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); | 109 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); |
112 #else | 110 #else |
113 // Ash Shell can't just live on its own without a browser process, we need to | 111 // Ash Shell can't just live on its own without a browser process, we need to |
114 // also create the message center. | 112 // also create the message center. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 chromeos::CrasAudioHandler::Shutdown(); | 151 chromeos::CrasAudioHandler::Shutdown(); |
154 #endif | 152 #endif |
155 // Ash Shell can't just live on its own without a browser process, we need to | 153 // Ash Shell can't just live on its own without a browser process, we need to |
156 // also shut down the message center. | 154 // also shut down the message center. |
157 message_center::MessageCenter::Shutdown(); | 155 message_center::MessageCenter::Shutdown(); |
158 aura::Env::DeleteInstance(); | 156 aura::Env::DeleteInstance(); |
159 #endif | 157 #endif |
160 #elif defined(USE_AURA) | 158 #elif defined(USE_AURA) |
161 aura_test_helper_->TearDown(); | 159 aura_test_helper_->TearDown(); |
162 #endif | 160 #endif |
163 ui::CompositorTestSupport::Terminate(); | |
164 ui::TextInputTestSupport::Shutdown(); | 161 ui::TextInputTestSupport::Shutdown(); |
165 } | 162 } |
166 | 163 |
167 bool ViewEventTestBase::CanResize() const { | 164 bool ViewEventTestBase::CanResize() const { |
168 return true; | 165 return true; |
169 } | 166 } |
170 | 167 |
171 views::View* ViewEventTestBase::GetContentsView() { | 168 views::View* ViewEventTestBase::GetContentsView() { |
172 if (!content_view_) { | 169 if (!content_view_) { |
173 // Wrap the real view (as returned by CreateContentsView) in a View so | 170 // Wrap the real view (as returned by CreateContentsView) in a View so |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 dnd_thread_.reset(NULL); | 222 dnd_thread_.reset(NULL); |
226 } | 223 } |
227 | 224 |
228 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 225 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
229 StopBackgroundThread(); | 226 StopBackgroundThread(); |
230 | 227 |
231 task.Run(); | 228 task.Run(); |
232 if (HasFatalFailure()) | 229 if (HasFatalFailure()) |
233 Done(); | 230 Done(); |
234 } | 231 } |
OLD | NEW |