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" | |
33 #include "ui/aura/window_event_dispatcher.h" | 32 #include "ui/aura/window_event_dispatcher.h" |
34 #include "ui/aura/window_tree_host.h" | 33 #include "ui/aura/window_tree_host.h" |
35 #include "ui/compositor/test/context_factories_for_test.h" | 34 #include "ui/compositor/test/context_factories_for_test.h" |
36 #include "ui/wm/core/wm_state.h" | 35 #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 AuraTestHelper to create and manage | 144 // Instead of using the ash shell, use an WMTestHelper to create and manage |
145 // the test screen. | 145 // the test screen. |
146 aura_test_helper_.reset( | 146 wm_test_helper_.reset(new wm::WMTestHelper); |
147 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); | 147 wm_test_helper_->SetUp(); |
148 aura_test_helper_->SetUp(); | 148 context = wm_test_helper_->root_window(); |
149 context = aura_test_helper_->root_window(); | |
150 #endif // !USE_ASH && USE_AURA | 149 #endif // !USE_ASH && USE_AURA |
151 | 150 |
152 window_ = views::Widget::CreateWindowWithContext(this, context); | 151 window_ = views::Widget::CreateWindowWithContext(this, context); |
153 } | 152 } |
154 | 153 |
155 void ViewEventTestBase::TearDown() { | 154 void ViewEventTestBase::TearDown() { |
156 if (window_) { | 155 if (window_) { |
157 window_->Close(); | 156 window_->Close(); |
158 content::RunAllPendingInMessageLoop(); | 157 content::RunAllPendingInMessageLoop(); |
159 window_ = NULL; | 158 window_ = NULL; |
160 } | 159 } |
161 | 160 |
162 ui::Clipboard::DestroyClipboardForCurrentThread(); | 161 ui::Clipboard::DestroyClipboardForCurrentThread(); |
163 | 162 |
164 #if defined(USE_ASH) | 163 #if defined(USE_ASH) |
165 #if !defined(OS_WIN) | 164 #if !defined(OS_WIN) |
166 ash::Shell::DeleteInstance(); | 165 ash::Shell::DeleteInstance(); |
167 #if defined(OS_CHROMEOS) | 166 #if defined(OS_CHROMEOS) |
168 chromeos::NetworkHandler::Shutdown(); | 167 chromeos::NetworkHandler::Shutdown(); |
169 chromeos::CrasAudioHandler::Shutdown(); | 168 chromeos::CrasAudioHandler::Shutdown(); |
170 chromeos::DBusThreadManager::Shutdown(); | 169 chromeos::DBusThreadManager::Shutdown(); |
171 #endif | 170 #endif |
172 // Ash Shell can't just live on its own without a browser process, we need to | 171 // Ash Shell can't just live on its own without a browser process, we need to |
173 // also shut down the message center. | 172 // also shut down the message center. |
174 message_center::MessageCenter::Shutdown(); | 173 message_center::MessageCenter::Shutdown(); |
175 #endif // !OS_WIN | 174 #endif // !OS_WIN |
176 aura::Env::DeleteInstance(); | 175 aura::Env::DeleteInstance(); |
177 #elif defined(USE_AURA) | 176 #elif defined(USE_AURA) |
178 aura_test_helper_->TearDown(); | 177 wm_test_helper_->TearDown(); |
179 #endif // !USE_ASH && USE_AURA | 178 #endif // !USE_ASH && USE_AURA |
180 | 179 |
181 #if defined(USE_AURA) | 180 #if defined(USE_AURA) |
182 ui::TerminateContextFactoryForTests(); | 181 ui::TerminateContextFactoryForTests(); |
183 #endif | 182 #endif |
184 | 183 |
185 ui::ShutdownInputMethodForTesting(); | 184 ui::ShutdownInputMethodForTesting(); |
186 views::ViewsDelegate::views_delegate = NULL; | 185 views::ViewsDelegate::views_delegate = NULL; |
187 | 186 |
188 #if defined(USE_AURA) | 187 #if defined(USE_AURA) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 dnd_thread_.reset(NULL); | 251 dnd_thread_.reset(NULL); |
253 } | 252 } |
254 | 253 |
255 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 254 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
256 StopBackgroundThread(); | 255 StopBackgroundThread(); |
257 | 256 |
258 task.Run(); | 257 task.Run(); |
259 if (HasFatalFailure()) | 258 if (HasFatalFailure()) |
260 Done(); | 259 Done(); |
261 } | 260 } |
OLD | NEW |