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