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/compositor/test/compositor_test_support.h" |
17 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
18 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 18 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
19 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
20 | 20 |
| 21 #if defined(ENABLE_MESSAGE_CENTER) |
| 22 #include "ui/message_center/message_center.h" |
| 23 #endif |
| 24 |
21 #if defined(USE_ASH) | 25 #if defined(USE_ASH) |
22 #include "ash/shell.h" | 26 #include "ash/shell.h" |
23 #include "ash/test/test_shell_delegate.h" | 27 #include "ash/test/test_shell_delegate.h" |
24 #endif | 28 #endif |
25 | 29 |
26 #if defined(USE_AURA) | 30 #if defined(USE_AURA) |
27 #include "ui/aura/client/event_client.h" | 31 #include "ui/aura/client/event_client.h" |
28 #include "ui/aura/env.h" | 32 #include "ui/aura/env.h" |
29 #include "ui/aura/root_window.h" | 33 #include "ui/aura/root_window.h" |
30 #include "ui/aura/test/aura_test_helper.h" | 34 #include "ui/aura/test/aura_test_helper.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 ui::TextInputTestSupport::Initialize(); | 95 ui::TextInputTestSupport::Initialize(); |
92 ui::CompositorTestSupport::Initialize(); | 96 ui::CompositorTestSupport::Initialize(); |
93 gfx::NativeView context = NULL; | 97 gfx::NativeView context = NULL; |
94 #if defined(USE_ASH) | 98 #if defined(USE_ASH) |
95 #if defined(OS_WIN) | 99 #if defined(OS_WIN) |
96 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when | 100 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when |
97 // interactive_ui_tests is brought up on that platform. | 101 // interactive_ui_tests is brought up on that platform. |
98 gfx::Screen::SetScreenInstance( | 102 gfx::Screen::SetScreenInstance( |
99 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); | 103 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); |
100 #else | 104 #else |
| 105 #if defined(ENABLE_MESSAGE_CENTER) |
| 106 // Ash Shell can't just live on its own without a browser process, we need to |
| 107 // also create the message center. |
| 108 message_center::MessageCenter::Initialize(); |
| 109 #endif |
101 ash::Shell::CreateInstance(new ash::test::TestShellDelegate()); | 110 ash::Shell::CreateInstance(new ash::test::TestShellDelegate()); |
102 context = ash::Shell::GetPrimaryRootWindow(); | 111 context = ash::Shell::GetPrimaryRootWindow(); |
103 #endif | 112 #endif |
104 #elif defined(USE_AURA) | 113 #elif defined(USE_AURA) |
105 // Instead of using the ash shell, use an AuraTestHelper to create and manage | 114 // Instead of using the ash shell, use an AuraTestHelper to create and manage |
106 // the test screen. | 115 // the test screen. |
107 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 116 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); |
108 aura_test_helper_->SetUp(); | 117 aura_test_helper_->SetUp(); |
109 context = aura_test_helper_->root_window(); | 118 context = aura_test_helper_->root_window(); |
110 #endif | 119 #endif |
111 | 120 |
112 window_ = views::Widget::CreateWindowWithContext(this, context); | 121 window_ = views::Widget::CreateWindowWithContext(this, context); |
113 } | 122 } |
114 | 123 |
115 void ViewEventTestBase::TearDown() { | 124 void ViewEventTestBase::TearDown() { |
116 if (window_) { | 125 if (window_) { |
117 #if defined(OS_WIN) && !defined(USE_AURA) | 126 #if defined(OS_WIN) && !defined(USE_AURA) |
118 DestroyWindow(window_->GetNativeWindow()); | 127 DestroyWindow(window_->GetNativeWindow()); |
119 #else | 128 #else |
120 window_->Close(); | 129 window_->Close(); |
121 content::RunAllPendingInMessageLoop(); | 130 content::RunAllPendingInMessageLoop(); |
122 #endif | 131 #endif |
123 window_ = NULL; | 132 window_ = NULL; |
124 } | 133 } |
125 #if defined(USE_ASH) | 134 #if defined(USE_ASH) |
126 #if defined(OS_WIN) | 135 #if defined(OS_WIN) |
127 #else | 136 #else |
128 ash::Shell::DeleteInstance(); | 137 ash::Shell::DeleteInstance(); |
| 138 #if defined(ENABLE_MESSAGE_CENTER) |
| 139 // Ash Shell can't just live on its own without a browser process, we need to |
| 140 // also shut down the message center. |
| 141 message_center::MessageCenter::Shutdown(); |
| 142 #endif |
129 aura::Env::DeleteInstance(); | 143 aura::Env::DeleteInstance(); |
130 #endif | 144 #endif |
131 #elif defined(USE_AURA) | 145 #elif defined(USE_AURA) |
132 aura_test_helper_->TearDown(); | 146 aura_test_helper_->TearDown(); |
133 #endif | 147 #endif |
134 ui::CompositorTestSupport::Terminate(); | 148 ui::CompositorTestSupport::Terminate(); |
135 ui::TextInputTestSupport::Shutdown(); | 149 ui::TextInputTestSupport::Shutdown(); |
136 } | 150 } |
137 | 151 |
138 bool ViewEventTestBase::CanResize() const { | 152 bool ViewEventTestBase::CanResize() const { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 dnd_thread_.reset(NULL); | 211 dnd_thread_.reset(NULL); |
198 } | 212 } |
199 | 213 |
200 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 214 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
201 StopBackgroundThread(); | 215 StopBackgroundThread(); |
202 | 216 |
203 task.Run(); | 217 task.Run(); |
204 if (HasFatalFailure()) | 218 if (HasFatalFailure()) |
205 Done(); | 219 Done(); |
206 } | 220 } |
OLD | NEW |