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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 void ViewEventTestBase::SetUp() { | 103 void ViewEventTestBase::SetUp() { |
104 wm_state_.reset(new wm::WMState); | 104 wm_state_.reset(new wm::WMState); |
105 | 105 |
106 views::ViewsDelegate::views_delegate = &views_delegate_; | 106 views::ViewsDelegate::views_delegate = &views_delegate_; |
107 ui::InitializeInputMethodForTesting(); | 107 ui::InitializeInputMethodForTesting(); |
108 gfx::NativeView context = NULL; | 108 gfx::NativeView context = NULL; |
109 | 109 |
110 // The ContextFactory must exist before any Compositors are created. | 110 // The ContextFactory must exist before any Compositors are created. |
111 bool enable_pixel_output = false; | 111 bool enable_pixel_output = false; |
112 ui::InitializeContextFactoryForTests(enable_pixel_output); | 112 ui::ContextFactory* context_factory = |
| 113 ui::InitializeContextFactoryForTests(enable_pixel_output); |
113 | 114 |
114 #if defined(OS_CHROMEOS) | 115 #if defined(OS_CHROMEOS) |
115 // Ash Shell can't just live on its own without a browser process, we need to | 116 // Ash Shell can't just live on its own without a browser process, we need to |
116 // also create the message center. | 117 // also create the message center. |
117 message_center::MessageCenter::Initialize(); | 118 message_center::MessageCenter::Initialize(); |
118 chromeos::DBusThreadManager::InitializeWithStub(); | 119 chromeos::DBusThreadManager::InitializeWithStub(); |
119 chromeos::CrasAudioHandler::InitializeForTesting(); | 120 chromeos::CrasAudioHandler::InitializeForTesting(); |
120 chromeos::NetworkHandler::Initialize(); | 121 chromeos::NetworkHandler::Initialize(); |
121 ash::test::TestShellDelegate* shell_delegate = | 122 ash::test::TestShellDelegate* shell_delegate = |
122 new ash::test::TestShellDelegate(); | 123 new ash::test::TestShellDelegate(); |
123 ash::ShellInitParams init_params; | 124 ash::ShellInitParams init_params; |
124 init_params.delegate = shell_delegate; | 125 init_params.delegate = shell_delegate; |
| 126 init_params.context_factory = context_factory; |
125 ash::Shell::CreateInstance(init_params); | 127 ash::Shell::CreateInstance(init_params); |
126 shell_delegate->test_session_state_delegate() | 128 shell_delegate->test_session_state_delegate() |
127 ->SetActiveUserSessionStarted(true); | 129 ->SetActiveUserSessionStarted(true); |
128 context = ash::Shell::GetPrimaryRootWindow(); | 130 context = ash::Shell::GetPrimaryRootWindow(); |
129 context->GetHost()->Show(); | 131 context->GetHost()->Show(); |
130 #elif defined(USE_ASH) | 132 #elif defined(USE_ASH) |
131 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when | 133 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when |
132 // interactive_ui_tests is brought up on that platform. | 134 // interactive_ui_tests is brought up on that platform. |
133 gfx::Screen::SetScreenInstance( | 135 gfx::Screen::SetScreenInstance( |
134 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); | 136 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); |
135 aura::Env::CreateInstance(true); | 137 aura::Env::CreateInstance(true); |
| 138 aura::Env::GetInstance()->set_context_factory(context_factory); |
136 #elif defined(USE_AURA) | 139 #elif defined(USE_AURA) |
137 // Instead of using the ash shell, use an AuraTestHelper to create and manage | 140 // Instead of using the ash shell, use an AuraTestHelper to create and manage |
138 // the test screen. | 141 // the test screen. |
139 aura_test_helper_.reset( | 142 aura_test_helper_.reset( |
140 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); | 143 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); |
141 aura_test_helper_->SetUp(); | 144 aura_test_helper_->SetUp(context_factory); |
142 new wm::DefaultActivationClient(aura_test_helper_->root_window()); | 145 new wm::DefaultActivationClient(aura_test_helper_->root_window()); |
143 context = aura_test_helper_->root_window(); | 146 context = aura_test_helper_->root_window(); |
144 #endif | 147 #endif |
145 | 148 |
146 window_ = views::Widget::CreateWindowWithContext(this, context); | 149 window_ = views::Widget::CreateWindowWithContext(this, context); |
147 } | 150 } |
148 | 151 |
149 void ViewEventTestBase::TearDown() { | 152 void ViewEventTestBase::TearDown() { |
150 if (window_) { | 153 if (window_) { |
151 window_->Close(); | 154 window_->Close(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 dnd_thread_.reset(NULL); | 243 dnd_thread_.reset(NULL); |
241 } | 244 } |
242 | 245 |
243 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 246 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
244 StopBackgroundThread(); | 247 StopBackgroundThread(); |
245 | 248 |
246 task.Run(); | 249 task.Run(); |
247 if (HasFatalFailure()) | 250 if (HasFatalFailure()) |
248 Done(); | 251 Done(); |
249 } | 252 } |
OLD | NEW |