OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/test/ash_test_helper.h" | 5 #include "ash/test/ash_test_helper.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_controller_delegate_aura.h" | 7 #include "ash/accelerators/accelerator_controller_delegate_aura.h" |
8 #include "ash/aura/shell_port_classic.h" | 8 #include "ash/aura/shell_port_classic.h" |
9 #include "ash/mus/bridge/shell_port_mash.h" | 9 #include "ash/mus/bridge/shell_port_mash.h" |
10 #include "ash/mus/screen_mus.h" | 10 #include "ash/mus/screen_mus.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ash/wm_window.h" | 25 #include "ash/wm_window.h" |
26 #include "base/memory/ptr_util.h" | 26 #include "base/memory/ptr_util.h" |
27 #include "base/run_loop.h" | 27 #include "base/run_loop.h" |
28 #include "base/strings/string_split.h" | 28 #include "base/strings/string_split.h" |
29 #include "base/test/sequenced_worker_pool_owner.h" | 29 #include "base/test/sequenced_worker_pool_owner.h" |
30 #include "chromeos/audio/cras_audio_handler.h" | 30 #include "chromeos/audio/cras_audio_handler.h" |
31 #include "chromeos/dbus/dbus_thread_manager.h" | 31 #include "chromeos/dbus/dbus_thread_manager.h" |
32 #include "chromeos/network/network_handler.h" | 32 #include "chromeos/network/network_handler.h" |
33 #include "device/bluetooth/bluetooth_adapter_factory.h" | 33 #include "device/bluetooth/bluetooth_adapter_factory.h" |
34 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | 34 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| 35 #include "services/ui/public/cpp/input_devices/input_device_client.h" |
35 #include "ui/aura/env.h" | 36 #include "ui/aura/env.h" |
36 #include "ui/aura/input_state_lookup.h" | 37 #include "ui/aura/input_state_lookup.h" |
37 #include "ui/aura/mus/window_tree_client.h" | 38 #include "ui/aura/mus/window_tree_client.h" |
38 #include "ui/aura/test/env_test_helper.h" | 39 #include "ui/aura/test/env_test_helper.h" |
39 #include "ui/aura/test/event_generator_delegate_aura.h" | 40 #include "ui/aura/test/event_generator_delegate_aura.h" |
40 #include "ui/aura/test/mus/window_tree_client_private.h" | 41 #include "ui/aura/test/mus/window_tree_client_private.h" |
41 #include "ui/base/ime/input_method_initializer.h" | 42 #include "ui/base/ime/input_method_initializer.h" |
42 #include "ui/base/material_design/material_design_controller.h" | 43 #include "ui/base/material_design/material_design_controller.h" |
43 #include "ui/base/platform_window_defaults.h" | 44 #include "ui/base/platform_window_defaults.h" |
44 #include "ui/base/test/material_design_controller_test_api.h" | 45 #include "ui/base/test/material_design_controller_test_api.h" |
(...skipping 30 matching lines...) Expand all Loading... |
75 test_screenshot_delegate_(nullptr), | 76 test_screenshot_delegate_(nullptr), |
76 dbus_thread_manager_initialized_(false), | 77 dbus_thread_manager_initialized_(false), |
77 bluez_dbus_manager_initialized_(false) { | 78 bluez_dbus_manager_initialized_(false) { |
78 ui::test::EnableTestConfigForPlatformWindows(); | 79 ui::test::EnableTestConfigForPlatformWindows(); |
79 aura::test::InitializeAuraEventGeneratorDelegate(); | 80 aura::test::InitializeAuraEventGeneratorDelegate(); |
80 } | 81 } |
81 | 82 |
82 AshTestHelper::~AshTestHelper() {} | 83 AshTestHelper::~AshTestHelper() {} |
83 | 84 |
84 void AshTestHelper::SetUp(bool start_session) { | 85 void AshTestHelper::SetUp(bool start_session) { |
| 86 if (config_ == Config::MUS) |
| 87 input_device_client_ = base::MakeUnique<ui::InputDeviceClient>(); |
| 88 |
85 display::ResetDisplayIdForTest(); | 89 display::ResetDisplayIdForTest(); |
86 if (config_ != Config::CLASSIC) | 90 if (config_ != Config::CLASSIC) |
87 aura::test::EnvTestHelper().SetAlwaysUseLastMouseLocation(true); | 91 aura::test::EnvTestHelper().SetAlwaysUseLastMouseLocation(true); |
88 // WindowManager creates WMState for mash. | 92 // WindowManager creates WMState for mash. |
89 if (config_ == Config::CLASSIC) | 93 if (config_ == Config::CLASSIC) |
90 wm_state_ = base::MakeUnique<::wm::WMState>(); | 94 wm_state_ = base::MakeUnique<::wm::WMState>(); |
91 test_views_delegate_ = ash_test_environment_->CreateViewsDelegate(); | 95 test_views_delegate_ = ash_test_environment_->CreateViewsDelegate(); |
92 | 96 |
93 // Disable animations during tests. | 97 // Disable animations during tests. |
94 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( | 98 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 device::BluetoothAdapterFactory::Shutdown(); | 209 device::BluetoothAdapterFactory::Shutdown(); |
206 bluez::BluezDBusManager::Shutdown(); | 210 bluez::BluezDBusManager::Shutdown(); |
207 bluez_dbus_manager_initialized_ = false; | 211 bluez_dbus_manager_initialized_ = false; |
208 } | 212 } |
209 | 213 |
210 if (dbus_thread_manager_initialized_) { | 214 if (dbus_thread_manager_initialized_) { |
211 chromeos::DBusThreadManager::Shutdown(); | 215 chromeos::DBusThreadManager::Shutdown(); |
212 dbus_thread_manager_initialized_ = false; | 216 dbus_thread_manager_initialized_ = false; |
213 } | 217 } |
214 | 218 |
215 ui::TerminateContextFactoryForTests(); | 219 if (config_ == Config::CLASSIC) |
| 220 ui::TerminateContextFactoryForTests(); |
216 | 221 |
217 ui::ShutdownInputMethodForTesting(); | 222 ui::ShutdownInputMethodForTesting(); |
218 zero_duration_mode_.reset(); | 223 zero_duration_mode_.reset(); |
219 | 224 |
220 test_views_delegate_.reset(); | 225 test_views_delegate_.reset(); |
221 wm_state_.reset(); | 226 wm_state_.reset(); |
222 | 227 |
| 228 input_device_client_.reset(); |
| 229 |
223 // WindowManager owns the CaptureController for mus/mash. | 230 // WindowManager owns the CaptureController for mus/mash. |
224 CHECK(config_ != Config::CLASSIC || !::wm::CaptureController::Get()); | 231 CHECK(config_ != Config::CLASSIC || !::wm::CaptureController::Get()); |
225 } | 232 } |
226 | 233 |
227 void AshTestHelper::RunAllPendingInMessageLoop() { | 234 void AshTestHelper::RunAllPendingInMessageLoop() { |
228 base::RunLoop run_loop; | 235 base::RunLoop run_loop; |
229 run_loop.RunUntilIdle(); | 236 run_loop.RunUntilIdle(); |
230 } | 237 } |
231 | 238 |
232 // static | 239 // static |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 276 } |
270 const bool in_shutdown = false; | 277 const bool in_shutdown = false; |
271 while (root_window_controllers.size() > parts.size()) { | 278 while (root_window_controllers.size() > parts.size()) { |
272 window_manager_app_->window_manager()->DestroyRootWindowController( | 279 window_manager_app_->window_manager()->DestroyRootWindowController( |
273 root_window_controllers.back(), in_shutdown); | 280 root_window_controllers.back(), in_shutdown); |
274 root_window_controllers.pop_back(); | 281 root_window_controllers.pop_back(); |
275 } | 282 } |
276 } | 283 } |
277 | 284 |
278 display::Display AshTestHelper::GetSecondaryDisplay() { | 285 display::Display AshTestHelper::GetSecondaryDisplay() { |
279 if (config_ == Config::CLASSIC) | 286 if (config_ != Config::MASH) |
280 return Shell::Get()->display_manager()->GetSecondaryDisplay(); | 287 return Shell::Get()->display_manager()->GetSecondaryDisplay(); |
281 | 288 |
282 std::vector<RootWindowController*> roots = GetRootsOrderedByDisplayId(); | 289 std::vector<RootWindowController*> roots = GetRootsOrderedByDisplayId(); |
283 CHECK_LE(2U, roots.size()); | 290 CHECK_LE(2U, roots.size()); |
284 return roots.size() < 2 ? display::Display() | 291 return roots.size() < 2 ? display::Display() |
285 : roots[1]->GetWindow()->GetDisplayNearestWindow(); | 292 : roots[1]->GetWindow()->GetDisplayNearestWindow(); |
286 } | 293 } |
287 | 294 |
288 void AshTestHelper::CreateMashWindowManager() { | 295 void AshTestHelper::CreateMashWindowManager() { |
289 CHECK(config_ != Config::CLASSIC); | 296 CHECK(config_ != Config::CLASSIC); |
290 window_manager_app_ = base::MakeUnique<mus::WindowManagerApplication>(); | 297 const bool show_primary_root_on_connect = false; |
| 298 window_manager_app_ = base::MakeUnique<mus::WindowManagerApplication>( |
| 299 show_primary_root_on_connect); |
291 | 300 |
292 window_manager_app_->window_manager_.reset( | 301 window_manager_app_->window_manager_.reset( |
293 new mus::WindowManager(nullptr, config_)); | 302 new mus::WindowManager(nullptr, config_, show_primary_root_on_connect)); |
294 window_manager_app_->window_manager()->shell_delegate_.reset( | 303 window_manager_app_->window_manager()->shell_delegate_.reset( |
295 test_shell_delegate_); | 304 test_shell_delegate_); |
296 window_manager_app_->window_manager() | 305 window_manager_app_->window_manager() |
297 ->create_session_state_delegate_stub_for_test_ = false; | 306 ->create_session_state_delegate_stub_for_test_ = false; |
298 | 307 |
299 window_tree_client_setup_.InitForWindowManager( | 308 window_tree_client_setup_.InitForWindowManager( |
300 window_manager_app_->window_manager_.get(), | 309 window_manager_app_->window_manager_.get(), |
301 window_manager_app_->window_manager_.get()); | 310 window_manager_app_->window_manager_.get()); |
302 aura::test::EnvTestHelper().SetWindowTreeClient( | 311 aura::test::EnvTestHelper().SetWindowTreeClient( |
303 window_tree_client_setup_.window_tree_client()); | 312 window_tree_client_setup_.window_tree_client()); |
304 // Classic ash does not start the NetworkHandler in tests, so don't start it | 313 // Classic ash does not start the NetworkHandler in tests, so don't start it |
305 // for mash either. The NetworkHandler may cause subtle side effects (such as | 314 // for mash either. The NetworkHandler may cause subtle side effects (such as |
306 // additional tray items) that can make for flaky tests. | 315 // additional tray items) that can make for flaky tests. |
307 const bool init_network_handler = false; | 316 const bool init_network_handler = false; |
308 window_manager_app_->InitWindowManager( | 317 window_manager_app_->InitWindowManager( |
309 window_tree_client_setup_.OwnWindowTreeClient(), | 318 window_tree_client_setup_.OwnWindowTreeClient(), |
310 ash_test_environment_->GetBlockingPool(), init_network_handler); | 319 ash_test_environment_->GetBlockingPool(), init_network_handler); |
311 | 320 |
312 aura::WindowTreeClient* window_tree_client = | 321 aura::WindowTreeClient* window_tree_client = |
313 window_manager_app_->window_manager()->window_tree_client(); | 322 window_manager_app_->window_manager()->window_tree_client(); |
314 window_tree_client_private_ = | 323 window_tree_client_private_ = |
315 base::MakeUnique<aura::WindowTreeClientPrivate>(window_tree_client); | 324 base::MakeUnique<aura::WindowTreeClientPrivate>(window_tree_client); |
316 int next_x = 0; | 325 if (config_ == Config::MUS) { |
317 CreateRootWindowController("800x600", &next_x); | 326 window_tree_client_private_->CallOnConnect(); |
| 327 } else { |
| 328 int next_x = 0; |
| 329 CreateRootWindowController("800x600", &next_x); |
| 330 } |
318 | 331 |
319 // Make sure the NetworkHandler didn't get turned on, see above comment as to | 332 // Make sure the NetworkHandler didn't get turned on, see above comment as to |
320 // why the NetworkHandler should not be running. | 333 // why the NetworkHandler should not be running. |
321 CHECK(!chromeos::NetworkHandler::IsInitialized()); | 334 CHECK(!chromeos::NetworkHandler::IsInitialized()); |
322 } | 335 } |
323 | 336 |
324 void AshTestHelper::CreateShell() { | 337 void AshTestHelper::CreateShell() { |
325 CHECK(config_ == Config::CLASSIC); | 338 CHECK(config_ == Config::CLASSIC); |
326 ui::ContextFactory* context_factory = nullptr; | 339 ui::ContextFactory* context_factory = nullptr; |
327 ui::ContextFactoryPrivate* context_factory_private = nullptr; | 340 ui::ContextFactoryPrivate* context_factory_private = nullptr; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 std::set<RootWindowController*> roots = | 389 std::set<RootWindowController*> roots = |
377 window_manager_app_->window_manager()->GetRootWindowControllers(); | 390 window_manager_app_->window_manager()->GetRootWindowControllers(); |
378 std::vector<RootWindowController*> ordered_roots; | 391 std::vector<RootWindowController*> ordered_roots; |
379 ordered_roots.insert(ordered_roots.begin(), roots.begin(), roots.end()); | 392 ordered_roots.insert(ordered_roots.begin(), roots.begin(), roots.end()); |
380 std::sort(ordered_roots.begin(), ordered_roots.end(), &CompareByDisplayId); | 393 std::sort(ordered_roots.begin(), ordered_roots.end(), &CompareByDisplayId); |
381 return ordered_roots; | 394 return ordered_roots; |
382 } | 395 } |
383 | 396 |
384 } // namespace test | 397 } // namespace test |
385 } // namespace ash | 398 } // namespace ash |
OLD | NEW |