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/message_loop.h" | 9 #include "base/message_loop/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_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "ui/base/ime/input_method_initializer.h" | 14 #include "ui/base/ime/input_method_initializer.h" |
15 #include "ui/base/test/ui_controls.h" | 15 #include "ui/base/test/ui_controls.h" |
| 16 #include "ui/compositor/test/context_factories_for_test.h" |
16 #include "ui/message_center/message_center.h" | 17 #include "ui/message_center/message_center.h" |
17 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
18 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 19 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
20 | 21 |
21 #if defined(USE_ASH) | 22 #if defined(USE_ASH) |
22 #include "ash/shell.h" | 23 #include "ash/shell.h" |
23 #include "ash/test/test_session_state_delegate.h" | 24 #include "ash/test/test_session_state_delegate.h" |
24 #include "ash/test/test_shell_delegate.h" | 25 #include "ash/test/test_shell_delegate.h" |
25 #if defined(OS_WIN) | |
26 #include "ui/compositor/compositor.h" | |
27 #endif | |
28 #endif | 26 #endif |
29 | 27 |
30 #if defined(USE_AURA) | 28 #if defined(USE_AURA) |
31 #include "ui/aura/client/event_client.h" | 29 #include "ui/aura/client/event_client.h" |
32 #include "ui/aura/env.h" | 30 #include "ui/aura/env.h" |
33 #include "ui/aura/root_window.h" | 31 #include "ui/aura/root_window.h" |
34 #include "ui/aura/test/aura_test_helper.h" | 32 #include "ui/aura/test/aura_test_helper.h" |
35 #endif | 33 #endif |
36 | 34 |
37 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 ui_controls::RunClosureAfterAllPendingUIEvents( | 93 ui_controls::RunClosureAfterAllPendingUIEvents( |
96 base::MessageLoop::QuitClosure()); | 94 base::MessageLoop::QuitClosure()); |
97 } | 95 } |
98 | 96 |
99 void ViewEventTestBase::SetUp() { | 97 void ViewEventTestBase::SetUp() { |
100 views::ViewsDelegate::views_delegate = &views_delegate_; | 98 views::ViewsDelegate::views_delegate = &views_delegate_; |
101 ui::InitializeInputMethodForTesting(); | 99 ui::InitializeInputMethodForTesting(); |
102 gfx::NativeView context = NULL; | 100 gfx::NativeView context = NULL; |
103 | 101 |
104 #if defined(USE_ASH) | 102 #if defined(USE_ASH) |
| 103 // The ContextFactory must exist before any Compositors are created. |
| 104 bool allow_test_contexts = true; |
| 105 ui::InitializeContextFactoryForTests(allow_test_contexts); |
105 #if defined(OS_WIN) | 106 #if defined(OS_WIN) |
106 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when | 107 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when |
107 // interactive_ui_tests is brought up on that platform. | 108 // interactive_ui_tests is brought up on that platform. |
108 gfx::Screen::SetScreenInstance( | 109 gfx::Screen::SetScreenInstance( |
109 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); | 110 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); |
110 | 111 |
111 // The ContextFactory must exist before any Compositors are created. The | |
112 // ash::Shell code path below handles this, but since we skip it we must | |
113 // do this here. | |
114 bool allow_test_contexts = true; | |
115 ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts); | |
116 #else // !OS_WIN | 112 #else // !OS_WIN |
117 // Ash Shell can't just live on its own without a browser process, we need to | 113 // Ash Shell can't just live on its own without a browser process, we need to |
118 // also create the message center. | 114 // also create the message center. |
119 message_center::MessageCenter::Initialize(); | 115 message_center::MessageCenter::Initialize(); |
120 #if defined(OS_CHROMEOS) | 116 #if defined(OS_CHROMEOS) |
121 chromeos::CrasAudioHandler::InitializeForTesting(); | 117 chromeos::CrasAudioHandler::InitializeForTesting(); |
122 chromeos::NetworkHandler::Initialize(); | 118 chromeos::NetworkHandler::Initialize(); |
123 #endif // OS_CHROMEOS | 119 #endif // OS_CHROMEOS |
124 ash::test::TestShellDelegate* shell_delegate = | 120 ash::test::TestShellDelegate* shell_delegate = |
125 new ash::test::TestShellDelegate(); | 121 new ash::test::TestShellDelegate(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 ash::Shell::DeleteInstance(); | 153 ash::Shell::DeleteInstance(); |
158 #if defined(OS_CHROMEOS) | 154 #if defined(OS_CHROMEOS) |
159 chromeos::NetworkHandler::Shutdown(); | 155 chromeos::NetworkHandler::Shutdown(); |
160 chromeos::CrasAudioHandler::Shutdown(); | 156 chromeos::CrasAudioHandler::Shutdown(); |
161 #endif | 157 #endif |
162 // Ash Shell can't just live on its own without a browser process, we need to | 158 // Ash Shell can't just live on its own without a browser process, we need to |
163 // also shut down the message center. | 159 // also shut down the message center. |
164 message_center::MessageCenter::Shutdown(); | 160 message_center::MessageCenter::Shutdown(); |
165 #endif // !OS_WIN | 161 #endif // !OS_WIN |
166 aura::Env::DeleteInstance(); | 162 aura::Env::DeleteInstance(); |
| 163 ui::TerminateContextFactoryForTests(); |
167 #elif defined(USE_AURA) | 164 #elif defined(USE_AURA) |
168 aura_test_helper_->TearDown(); | 165 aura_test_helper_->TearDown(); |
169 #endif // !USE_ASH && USE_AURA | 166 #endif // !USE_ASH && USE_AURA |
170 | 167 |
171 ui::ShutdownInputMethodForTesting(); | 168 ui::ShutdownInputMethodForTesting(); |
172 views::ViewsDelegate::views_delegate = NULL; | 169 views::ViewsDelegate::views_delegate = NULL; |
173 } | 170 } |
174 | 171 |
175 bool ViewEventTestBase::CanResize() const { | 172 bool ViewEventTestBase::CanResize() const { |
176 return true; | 173 return true; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 dnd_thread_.reset(NULL); | 230 dnd_thread_.reset(NULL); |
234 } | 231 } |
235 | 232 |
236 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 233 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
237 StopBackgroundThread(); | 234 StopBackgroundThread(); |
238 | 235 |
239 task.Run(); | 236 task.Run(); |
240 if (HasFatalFailure()) | 237 if (HasFatalFailure()) |
241 Done(); | 238 Done(); |
242 } | 239 } |
OLD | NEW |