| 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 13 matching lines...) Expand all Loading... |
| 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/root_window.h" | 32 #include "ui/aura/root_window.h" |
| 33 #include "ui/aura/test/aura_test_helper.h" | 33 #include "ui/aura/test/aura_test_helper.h" |
| 34 #include "ui/views/corewm/wm_state.h" |
| 34 #endif | 35 #endif |
| 35 | 36 |
| 36 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 37 #include "chromeos/audio/cras_audio_handler.h" | 38 #include "chromeos/audio/cras_audio_handler.h" |
| 38 #include "chromeos/dbus/dbus_thread_manager.h" | 39 #include "chromeos/dbus/dbus_thread_manager.h" |
| 39 #include "chromeos/network/network_handler.h" | 40 #include "chromeos/network/network_handler.h" |
| 40 #endif | 41 #endif |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 94 |
| 94 // If we're in a nested message loop, as is the case with menus, we | 95 // If we're in a nested message loop, as is the case with menus, we |
| 95 // need to quit twice. The second quit does that for us. Finish all | 96 // need to quit twice. The second quit does that for us. Finish all |
| 96 // pending UI events before posting closure because events it may be | 97 // pending UI events before posting closure because events it may be |
| 97 // executed before UI events are executed. | 98 // executed before UI events are executed. |
| 98 ui_controls::RunClosureAfterAllPendingUIEvents( | 99 ui_controls::RunClosureAfterAllPendingUIEvents( |
| 99 base::MessageLoop::QuitClosure()); | 100 base::MessageLoop::QuitClosure()); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void ViewEventTestBase::SetUp() { | 103 void ViewEventTestBase::SetUp() { |
| 104 #if defined(USE_AURA) |
| 105 wm_state_.reset(new views::corewm::WMState); |
| 106 #endif |
| 107 |
| 103 views::ViewsDelegate::views_delegate = &views_delegate_; | 108 views::ViewsDelegate::views_delegate = &views_delegate_; |
| 104 ui::InitializeInputMethodForTesting(); | 109 ui::InitializeInputMethodForTesting(); |
| 105 gfx::NativeView context = NULL; | 110 gfx::NativeView context = NULL; |
| 106 | 111 |
| 107 #if defined(USE_ASH) | 112 #if defined(USE_ASH) |
| 108 // The ContextFactory must exist before any Compositors are created. | 113 // The ContextFactory must exist before any Compositors are created. |
| 109 bool allow_test_contexts = true; | 114 bool allow_test_contexts = true; |
| 110 ui::InitializeContextFactoryForTests(allow_test_contexts); | 115 ui::InitializeContextFactoryForTests(allow_test_contexts); |
| 111 #if defined(OS_WIN) | 116 #if defined(OS_WIN) |
| 112 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when | 117 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 message_center::MessageCenter::Shutdown(); | 172 message_center::MessageCenter::Shutdown(); |
| 168 #endif // !OS_WIN | 173 #endif // !OS_WIN |
| 169 aura::Env::DeleteInstance(); | 174 aura::Env::DeleteInstance(); |
| 170 ui::TerminateContextFactoryForTests(); | 175 ui::TerminateContextFactoryForTests(); |
| 171 #elif defined(USE_AURA) | 176 #elif defined(USE_AURA) |
| 172 aura_test_helper_->TearDown(); | 177 aura_test_helper_->TearDown(); |
| 173 #endif // !USE_ASH && USE_AURA | 178 #endif // !USE_ASH && USE_AURA |
| 174 | 179 |
| 175 ui::ShutdownInputMethodForTesting(); | 180 ui::ShutdownInputMethodForTesting(); |
| 176 views::ViewsDelegate::views_delegate = NULL; | 181 views::ViewsDelegate::views_delegate = NULL; |
| 182 |
| 183 #if defined(USE_AURA) |
| 184 wm_state_.reset(); |
| 185 #endif |
| 177 } | 186 } |
| 178 | 187 |
| 179 bool ViewEventTestBase::CanResize() const { | 188 bool ViewEventTestBase::CanResize() const { |
| 180 return true; | 189 return true; |
| 181 } | 190 } |
| 182 | 191 |
| 183 views::View* ViewEventTestBase::GetContentsView() { | 192 views::View* ViewEventTestBase::GetContentsView() { |
| 184 if (!content_view_) { | 193 if (!content_view_) { |
| 185 // Wrap the real view (as returned by CreateContentsView) in a View so | 194 // Wrap the real view (as returned by CreateContentsView) in a View so |
| 186 // that we can customize the preferred size. | 195 // that we can customize the preferred size. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 dnd_thread_.reset(NULL); | 247 dnd_thread_.reset(NULL); |
| 239 } | 248 } |
| 240 | 249 |
| 241 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 250 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
| 242 StopBackgroundThread(); | 251 StopBackgroundThread(); |
| 243 | 252 |
| 244 task.Run(); | 253 task.Run(); |
| 245 if (HasFatalFailure()) | 254 if (HasFatalFailure()) |
| 246 Done(); | 255 Done(); |
| 247 } | 256 } |
| OLD | NEW |