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" |
| 11 #include "chrome/test/base/chrome_unit_test_suite.h" |
11 #include "chrome/test/base/interactive_test_utils.h" | 12 #include "chrome/test/base/interactive_test_utils.h" |
12 #include "chrome/test/base/testing_browser_process.h" | 13 #include "chrome/test/base/testing_browser_process.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
14 #include "ui/base/ime/input_method_initializer.h" | 15 #include "ui/base/ime/input_method_initializer.h" |
15 #include "ui/base/test/ui_controls.h" | 16 #include "ui/base/test/ui_controls.h" |
16 #include "ui/compositor/test/context_factories_for_test.h" | 17 #include "ui/compositor/test/context_factories_for_test.h" |
17 #include "ui/message_center/message_center.h" | 18 #include "ui/message_center/message_center.h" |
18 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
19 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 20 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
20 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 base::MessageLoop::current()->Quit(); | 88 base::MessageLoop::current()->Quit(); |
88 | 89 |
89 // If we're in a nested message loop, as is the case with menus, we | 90 // If we're in a nested message loop, as is the case with menus, we |
90 // need to quit twice. The second quit does that for us. Finish all | 91 // need to quit twice. The second quit does that for us. Finish all |
91 // pending UI events before posting closure because events it may be | 92 // pending UI events before posting closure because events it may be |
92 // executed before UI events are executed. | 93 // executed before UI events are executed. |
93 ui_controls::RunClosureAfterAllPendingUIEvents( | 94 ui_controls::RunClosureAfterAllPendingUIEvents( |
94 base::MessageLoop::QuitClosure()); | 95 base::MessageLoop::QuitClosure()); |
95 } | 96 } |
96 | 97 |
| 98 void ViewEventTestBase::SetUpTestCase() { |
| 99 ChromeUnitTestSuite::InitializeProviders(); |
| 100 ChromeUnitTestSuite::InitializeResourceBundle(); |
| 101 } |
| 102 |
97 void ViewEventTestBase::SetUp() { | 103 void ViewEventTestBase::SetUp() { |
98 #if defined(USE_AURA) | 104 #if defined(USE_AURA) |
99 wm_state_.reset(new wm::WMState); | 105 wm_state_.reset(new wm::WMState); |
100 #endif | 106 #endif |
101 | 107 |
102 views::ViewsDelegate::views_delegate = &views_delegate_; | 108 views::ViewsDelegate::views_delegate = &views_delegate_; |
103 ui::InitializeInputMethodForTesting(); | 109 ui::InitializeInputMethodForTesting(); |
104 gfx::NativeView context = NULL; | 110 gfx::NativeView context = NULL; |
105 | 111 |
106 #if defined(USE_AURA) | 112 #if defined(USE_AURA) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 dnd_thread_.reset(NULL); | 252 dnd_thread_.reset(NULL); |
247 } | 253 } |
248 | 254 |
249 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 255 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
250 StopBackgroundThread(); | 256 StopBackgroundThread(); |
251 | 257 |
252 task.Run(); | 258 task.Run(); |
253 if (HasFatalFailure()) | 259 if (HasFatalFailure()) |
254 Done(); | 260 Done(); |
255 } | 261 } |
OLD | NEW |