| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 ui::InitializeInputMethodForTesting(); | 110 ui::InitializeInputMethodForTesting(); |
| 111 gfx::NativeView context = NULL; | 111 gfx::NativeView context = NULL; |
| 112 | 112 |
| 113 #if defined(USE_AURA) | 113 #if defined(USE_AURA) |
| 114 // The ContextFactory must exist before any Compositors are created. | 114 // The ContextFactory must exist before any Compositors are created. |
| 115 bool enable_pixel_output = false; | 115 bool enable_pixel_output = false; |
| 116 ui::InitializeContextFactoryForTests(enable_pixel_output); | 116 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 117 #endif | 117 #endif |
| 118 | 118 |
| 119 #if defined(USE_ASH) | 119 #if defined(USE_ASH) |
| 120 #if defined(OS_WIN) | 120 #if !defined(OS_CHROMEOS) |
| 121 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when | 121 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when |
| 122 // interactive_ui_tests is brought up on that platform. | 122 // interactive_ui_tests is brought up on that platform. |
| 123 gfx::Screen::SetScreenInstance( | 123 gfx::Screen::SetScreenInstance( |
| 124 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); | 124 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); |
| 125 | 125 |
| 126 #else // !OS_WIN | 126 #else // !OS_CHROMEOS |
| 127 // Ash Shell can't just live on its own without a browser process, we need to | 127 // Ash Shell can't just live on its own without a browser process, we need to |
| 128 // also create the message center. | 128 // also create the message center. |
| 129 message_center::MessageCenter::Initialize(); | 129 message_center::MessageCenter::Initialize(); |
| 130 #if defined(OS_CHROMEOS) | 130 #if defined(OS_CHROMEOS) |
| 131 chromeos::DBusThreadManager::InitializeWithStub(); | 131 chromeos::DBusThreadManager::InitializeWithStub(); |
| 132 chromeos::CrasAudioHandler::InitializeForTesting(); | 132 chromeos::CrasAudioHandler::InitializeForTesting(); |
| 133 chromeos::NetworkHandler::Initialize(); | 133 chromeos::NetworkHandler::Initialize(); |
| 134 #endif // OS_CHROMEOS | 134 #endif // OS_CHROMEOS |
| 135 ash::test::TestShellDelegate* shell_delegate = | 135 ash::test::TestShellDelegate* shell_delegate = |
| 136 new ash::test::TestShellDelegate(); | 136 new ash::test::TestShellDelegate(); |
| 137 ash::Shell::CreateInstance(shell_delegate); | 137 ash::Shell::CreateInstance(shell_delegate); |
| 138 shell_delegate->test_session_state_delegate() | 138 shell_delegate->test_session_state_delegate() |
| 139 ->SetActiveUserSessionStarted(true); | 139 ->SetActiveUserSessionStarted(true); |
| 140 context = ash::Shell::GetPrimaryRootWindow(); | 140 context = ash::Shell::GetPrimaryRootWindow(); |
| 141 context->GetHost()->Show(); | 141 context->GetHost()->Show(); |
| 142 #endif // !OS_WIN | 142 #endif // !OS_CHROMEOS |
| 143 aura::Env::CreateInstance(); | 143 aura::Env::CreateInstance(); |
| 144 #elif defined(USE_AURA) | 144 #elif defined(USE_AURA) |
| 145 // Instead of using the ash shell, use an AuraTestHelper to create and manage | 145 // Instead of using the ash shell, use an AuraTestHelper to create and manage |
| 146 // the test screen. | 146 // the test screen. |
| 147 aura_test_helper_.reset( | 147 aura_test_helper_.reset( |
| 148 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); | 148 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); |
| 149 aura_test_helper_->SetUp(); | 149 aura_test_helper_->SetUp(); |
| 150 context = aura_test_helper_->root_window(); | 150 context = aura_test_helper_->root_window(); |
| 151 #endif // !USE_ASH && USE_AURA | 151 #endif // !USE_ASH && USE_AURA |
| 152 | 152 |
| 153 window_ = views::Widget::CreateWindowWithContext(this, context); | 153 window_ = views::Widget::CreateWindowWithContext(this, context); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void ViewEventTestBase::TearDown() { | 156 void ViewEventTestBase::TearDown() { |
| 157 if (window_) { | 157 if (window_) { |
| 158 window_->Close(); | 158 window_->Close(); |
| 159 content::RunAllPendingInMessageLoop(); | 159 content::RunAllPendingInMessageLoop(); |
| 160 window_ = NULL; | 160 window_ = NULL; |
| 161 } | 161 } |
| 162 | 162 |
| 163 ui::Clipboard::DestroyClipboardForCurrentThread(); | 163 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 164 | 164 |
| 165 #if defined(USE_ASH) | 165 #if defined(USE_ASH) |
| 166 #if !defined(OS_WIN) | 166 #if defined(OS_CHROMEOS) |
| 167 ash::Shell::DeleteInstance(); | 167 ash::Shell::DeleteInstance(); |
| 168 #if defined(OS_CHROMEOS) | |
| 169 chromeos::NetworkHandler::Shutdown(); | 168 chromeos::NetworkHandler::Shutdown(); |
| 170 chromeos::CrasAudioHandler::Shutdown(); | 169 chromeos::CrasAudioHandler::Shutdown(); |
| 171 chromeos::DBusThreadManager::Shutdown(); | 170 chromeos::DBusThreadManager::Shutdown(); |
| 172 #endif | |
| 173 // 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 |
| 174 // also shut down the message center. | 172 // also shut down the message center. |
| 175 message_center::MessageCenter::Shutdown(); | 173 message_center::MessageCenter::Shutdown(); |
| 176 #endif // !OS_WIN | 174 #endif |
| 177 aura::Env::DeleteInstance(); | 175 aura::Env::DeleteInstance(); |
| 178 #elif defined(USE_AURA) | 176 #elif defined(USE_AURA) |
| 179 aura_test_helper_->TearDown(); | 177 aura_test_helper_->TearDown(); |
| 180 #endif // !USE_ASH && USE_AURA | 178 #endif // !USE_ASH && USE_AURA |
| 181 | 179 |
| 182 #if defined(USE_AURA) | 180 #if defined(USE_AURA) |
| 183 ui::TerminateContextFactoryForTests(); | 181 ui::TerminateContextFactoryForTests(); |
| 184 #endif | 182 #endif |
| 185 | 183 |
| 186 ui::ShutdownInputMethodForTesting(); | 184 ui::ShutdownInputMethodForTesting(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 dnd_thread_.reset(NULL); | 251 dnd_thread_.reset(NULL); |
| 254 } | 252 } |
| 255 | 253 |
| 256 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 254 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
| 257 StopBackgroundThread(); | 255 StopBackgroundThread(); |
| 258 | 256 |
| 259 task.Run(); | 257 task.Run(); |
| 260 if (HasFatalFailure()) | 258 if (HasFatalFailure()) |
| 261 Done(); | 259 Done(); |
| 262 } | 260 } |
| OLD | NEW |