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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 #if defined(USE_ASH) | 23 #if defined(USE_ASH) |
24 #include "ash/shell.h" | 24 #include "ash/shell.h" |
25 #include "ash/test/test_session_state_delegate.h" | 25 #include "ash/test/test_session_state_delegate.h" |
26 #include "ash/test/test_shell_delegate.h" | 26 #include "ash/test/test_shell_delegate.h" |
27 #endif | 27 #endif |
28 | 28 |
29 #if defined(USE_AURA) | 29 #if defined(USE_AURA) |
30 #include "ui/aura/client/event_client.h" | 30 #include "ui/aura/client/event_client.h" |
31 #include "ui/aura/env.h" | 31 #include "ui/aura/env.h" |
| 32 #include "ui/aura/test/aura_test_helper.h" |
32 #include "ui/aura/window_event_dispatcher.h" | 33 #include "ui/aura/window_event_dispatcher.h" |
33 #include "ui/aura/window_tree_host.h" | 34 #include "ui/aura/window_tree_host.h" |
34 #include "ui/compositor/test/context_factories_for_test.h" | 35 #include "ui/compositor/test/context_factories_for_test.h" |
35 #include "ui/wm/core/wm_state.h" | 36 #include "ui/wm/core/wm_state.h" |
36 #include "ui/wm/test/wm_test_helper.h" | |
37 #endif | 37 #endif |
38 | 38 |
39 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
40 #include "chromeos/audio/cras_audio_handler.h" | 40 #include "chromeos/audio/cras_audio_handler.h" |
41 #include "chromeos/dbus/dbus_thread_manager.h" | 41 #include "chromeos/dbus/dbus_thread_manager.h" |
42 #include "chromeos/network/network_handler.h" | 42 #include "chromeos/network/network_handler.h" |
43 #endif | 43 #endif |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 ash::test::TestShellDelegate* shell_delegate = | 134 ash::test::TestShellDelegate* shell_delegate = |
135 new ash::test::TestShellDelegate(); | 135 new ash::test::TestShellDelegate(); |
136 ash::Shell::CreateInstance(shell_delegate); | 136 ash::Shell::CreateInstance(shell_delegate); |
137 shell_delegate->test_session_state_delegate() | 137 shell_delegate->test_session_state_delegate() |
138 ->SetActiveUserSessionStarted(true); | 138 ->SetActiveUserSessionStarted(true); |
139 context = ash::Shell::GetPrimaryRootWindow(); | 139 context = ash::Shell::GetPrimaryRootWindow(); |
140 context->GetHost()->Show(); | 140 context->GetHost()->Show(); |
141 #endif // !OS_WIN | 141 #endif // !OS_WIN |
142 aura::Env::CreateInstance(); | 142 aura::Env::CreateInstance(); |
143 #elif defined(USE_AURA) | 143 #elif defined(USE_AURA) |
144 // Instead of using the ash shell, use an WMTestHelper to create and manage | 144 // Instead of using the ash shell, use an AuraTestHelper to create and manage |
145 // the test screen. | 145 // the test screen. |
146 wm_test_helper_.reset(new wm::WMTestHelper); | 146 aura_test_helper_.reset( |
147 wm_test_helper_->SetUp(); | 147 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); |
148 context = wm_test_helper_->root_window(); | 148 aura_test_helper_->SetUp(); |
| 149 context = aura_test_helper_->root_window(); |
149 #endif // !USE_ASH && USE_AURA | 150 #endif // !USE_ASH && USE_AURA |
150 | 151 |
151 window_ = views::Widget::CreateWindowWithContext(this, context); | 152 window_ = views::Widget::CreateWindowWithContext(this, context); |
152 } | 153 } |
153 | 154 |
154 void ViewEventTestBase::TearDown() { | 155 void ViewEventTestBase::TearDown() { |
155 if (window_) { | 156 if (window_) { |
156 window_->Close(); | 157 window_->Close(); |
157 content::RunAllPendingInMessageLoop(); | 158 content::RunAllPendingInMessageLoop(); |
158 window_ = NULL; | 159 window_ = NULL; |
159 } | 160 } |
160 | 161 |
161 ui::Clipboard::DestroyClipboardForCurrentThread(); | 162 ui::Clipboard::DestroyClipboardForCurrentThread(); |
162 | 163 |
163 #if defined(USE_ASH) | 164 #if defined(USE_ASH) |
164 #if !defined(OS_WIN) | 165 #if !defined(OS_WIN) |
165 ash::Shell::DeleteInstance(); | 166 ash::Shell::DeleteInstance(); |
166 #if defined(OS_CHROMEOS) | 167 #if defined(OS_CHROMEOS) |
167 chromeos::NetworkHandler::Shutdown(); | 168 chromeos::NetworkHandler::Shutdown(); |
168 chromeos::CrasAudioHandler::Shutdown(); | 169 chromeos::CrasAudioHandler::Shutdown(); |
169 chromeos::DBusThreadManager::Shutdown(); | 170 chromeos::DBusThreadManager::Shutdown(); |
170 #endif | 171 #endif |
171 // Ash Shell can't just live on its own without a browser process, we need to | 172 // Ash Shell can't just live on its own without a browser process, we need to |
172 // also shut down the message center. | 173 // also shut down the message center. |
173 message_center::MessageCenter::Shutdown(); | 174 message_center::MessageCenter::Shutdown(); |
174 #endif // !OS_WIN | 175 #endif // !OS_WIN |
175 aura::Env::DeleteInstance(); | 176 aura::Env::DeleteInstance(); |
176 #elif defined(USE_AURA) | 177 #elif defined(USE_AURA) |
177 wm_test_helper_->TearDown(); | 178 aura_test_helper_->TearDown(); |
178 #endif // !USE_ASH && USE_AURA | 179 #endif // !USE_ASH && USE_AURA |
179 | 180 |
180 #if defined(USE_AURA) | 181 #if defined(USE_AURA) |
181 ui::TerminateContextFactoryForTests(); | 182 ui::TerminateContextFactoryForTests(); |
182 #endif | 183 #endif |
183 | 184 |
184 ui::ShutdownInputMethodForTesting(); | 185 ui::ShutdownInputMethodForTesting(); |
185 views::ViewsDelegate::views_delegate = NULL; | 186 views::ViewsDelegate::views_delegate = NULL; |
186 | 187 |
187 #if defined(USE_AURA) | 188 #if defined(USE_AURA) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 dnd_thread_.reset(NULL); | 252 dnd_thread_.reset(NULL); |
252 } | 253 } |
253 | 254 |
254 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 255 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
255 StopBackgroundThread(); | 256 StopBackgroundThread(); |
256 | 257 |
257 task.Run(); | 258 task.Run(); |
258 if (HasFatalFailure()) | 259 if (HasFatalFailure()) |
259 Done(); | 260 Done(); |
260 } | 261 } |
OLD | NEW |