| 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/ash_switches.h" | 8 #include "ash/ash_switches.h" |
| 9 #include "ash/aura/shell_port_classic.h" | 9 #include "ash/aura/shell_port_classic.h" |
| 10 #include "ash/mus/bridge/shell_port_mash.h" | 10 #include "ash/mus/bridge/shell_port_mash.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 device::BluetoothAdapterFactory::Shutdown(); | 233 device::BluetoothAdapterFactory::Shutdown(); |
| 234 bluez::BluezDBusManager::Shutdown(); | 234 bluez::BluezDBusManager::Shutdown(); |
| 235 bluez_dbus_manager_initialized_ = false; | 235 bluez_dbus_manager_initialized_ = false; |
| 236 } | 236 } |
| 237 | 237 |
| 238 if (dbus_thread_manager_initialized_) { | 238 if (dbus_thread_manager_initialized_) { |
| 239 chromeos::DBusThreadManager::Shutdown(); | 239 chromeos::DBusThreadManager::Shutdown(); |
| 240 dbus_thread_manager_initialized_ = false; | 240 dbus_thread_manager_initialized_ = false; |
| 241 } | 241 } |
| 242 | 242 |
| 243 ui::TerminateContextFactoryForTests(); | 243 if (config_ == Config::CLASSIC) |
| 244 ui::TerminateContextFactoryForTests(); |
| 244 | 245 |
| 245 ui::ShutdownInputMethodForTesting(); | 246 ui::ShutdownInputMethodForTesting(); |
| 246 zero_duration_mode_.reset(); | 247 zero_duration_mode_.reset(); |
| 247 | 248 |
| 248 test_views_delegate_.reset(); | 249 test_views_delegate_.reset(); |
| 249 wm_state_.reset(); | 250 wm_state_.reset(); |
| 250 | 251 |
| 251 input_device_client_.reset(); | 252 input_device_client_.reset(); |
| 252 | 253 |
| 253 command_line_.reset(); | 254 command_line_.reset(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 302 } |
| 302 const bool in_shutdown = false; | 303 const bool in_shutdown = false; |
| 303 while (root_window_controllers.size() > parts.size()) { | 304 while (root_window_controllers.size() > parts.size()) { |
| 304 window_manager_app_->window_manager()->DestroyRootWindowController( | 305 window_manager_app_->window_manager()->DestroyRootWindowController( |
| 305 root_window_controllers.back(), in_shutdown); | 306 root_window_controllers.back(), in_shutdown); |
| 306 root_window_controllers.pop_back(); | 307 root_window_controllers.pop_back(); |
| 307 } | 308 } |
| 308 } | 309 } |
| 309 | 310 |
| 310 display::Display AshTestHelper::GetSecondaryDisplay() { | 311 display::Display AshTestHelper::GetSecondaryDisplay() { |
| 311 if (config_ == Config::CLASSIC) | 312 if (config_ != Config::MASH) |
| 312 return Shell::Get()->display_manager()->GetSecondaryDisplay(); | 313 return Shell::Get()->display_manager()->GetSecondaryDisplay(); |
| 313 | 314 |
| 314 std::vector<RootWindowController*> roots = GetRootsOrderedByDisplayId(); | 315 std::vector<RootWindowController*> roots = GetRootsOrderedByDisplayId(); |
| 315 CHECK_LE(2U, roots.size()); | 316 CHECK_LE(2U, roots.size()); |
| 316 return roots.size() < 2 ? display::Display() | 317 return roots.size() < 2 ? display::Display() |
| 317 : roots[1]->GetWindow()->GetDisplayNearestWindow(); | 318 : roots[1]->GetWindow()->GetDisplayNearestWindow(); |
| 318 } | 319 } |
| 319 | 320 |
| 320 void AshTestHelper::CreateMashWindowManager() { | 321 void AshTestHelper::CreateMashWindowManager() { |
| 321 CHECK(config_ != Config::CLASSIC); | 322 CHECK(config_ != Config::CLASSIC); |
| 322 window_manager_app_ = base::MakeUnique<mus::WindowManagerApplication>(); | 323 const bool show_primary_root_on_connect = false; |
| 324 window_manager_app_ = base::MakeUnique<mus::WindowManagerApplication>( |
| 325 show_primary_root_on_connect); |
| 323 | 326 |
| 324 window_manager_app_->window_manager_.reset( | 327 window_manager_app_->window_manager_.reset( |
| 325 new mus::WindowManager(nullptr, config_)); | 328 new mus::WindowManager(nullptr, config_, show_primary_root_on_connect)); |
| 326 window_manager_app_->window_manager()->shell_delegate_.reset( | 329 window_manager_app_->window_manager()->shell_delegate_.reset( |
| 327 test_shell_delegate_); | 330 test_shell_delegate_); |
| 328 window_manager_app_->window_manager() | 331 window_manager_app_->window_manager() |
| 329 ->create_session_state_delegate_stub_for_test_ = false; | 332 ->create_session_state_delegate_stub_for_test_ = false; |
| 330 | 333 |
| 331 window_tree_client_setup_.InitForWindowManager( | 334 window_tree_client_setup_.InitForWindowManager( |
| 332 window_manager_app_->window_manager_.get(), | 335 window_manager_app_->window_manager_.get(), |
| 333 window_manager_app_->window_manager_.get()); | 336 window_manager_app_->window_manager_.get()); |
| 334 aura::test::EnvTestHelper().SetWindowTreeClient( | 337 aura::test::EnvTestHelper().SetWindowTreeClient( |
| 335 window_tree_client_setup_.window_tree_client()); | 338 window_tree_client_setup_.window_tree_client()); |
| 336 // Classic ash does not start the NetworkHandler in tests, so don't start it | 339 // Classic ash does not start the NetworkHandler in tests, so don't start it |
| 337 // for mash either. The NetworkHandler may cause subtle side effects (such as | 340 // for mash either. The NetworkHandler may cause subtle side effects (such as |
| 338 // additional tray items) that can make for flaky tests. | 341 // additional tray items) that can make for flaky tests. |
| 339 const bool init_network_handler = false; | 342 const bool init_network_handler = false; |
| 340 window_manager_app_->InitWindowManager( | 343 window_manager_app_->InitWindowManager( |
| 341 window_tree_client_setup_.OwnWindowTreeClient(), | 344 window_tree_client_setup_.OwnWindowTreeClient(), |
| 342 ash_test_environment_->GetBlockingPool(), init_network_handler); | 345 ash_test_environment_->GetBlockingPool(), init_network_handler); |
| 343 | 346 |
| 344 aura::WindowTreeClient* window_tree_client = | 347 aura::WindowTreeClient* window_tree_client = |
| 345 window_manager_app_->window_manager()->window_tree_client(); | 348 window_manager_app_->window_manager()->window_tree_client(); |
| 346 window_tree_client_private_ = | 349 window_tree_client_private_ = |
| 347 base::MakeUnique<aura::WindowTreeClientPrivate>(window_tree_client); | 350 base::MakeUnique<aura::WindowTreeClientPrivate>(window_tree_client); |
| 348 int next_x = 0; | 351 if (config_ == Config::MUS) { |
| 349 CreateRootWindowController("800x600", &next_x); | 352 window_tree_client_private_->CallOnConnect(); |
| 353 } else { |
| 354 int next_x = 0; |
| 355 CreateRootWindowController("800x600", &next_x); |
| 356 } |
| 350 | 357 |
| 351 // Make sure the NetworkHandler didn't get turned on, see above comment as to | 358 // Make sure the NetworkHandler didn't get turned on, see above comment as to |
| 352 // why the NetworkHandler should not be running. | 359 // why the NetworkHandler should not be running. |
| 353 CHECK(!chromeos::NetworkHandler::IsInitialized()); | 360 CHECK(!chromeos::NetworkHandler::IsInitialized()); |
| 354 } | 361 } |
| 355 | 362 |
| 356 void AshTestHelper::CreateShell() { | 363 void AshTestHelper::CreateShell() { |
| 357 CHECK(config_ == Config::CLASSIC); | 364 CHECK(config_ == Config::CLASSIC); |
| 358 ui::ContextFactory* context_factory = nullptr; | 365 ui::ContextFactory* context_factory = nullptr; |
| 359 ui::ContextFactoryPrivate* context_factory_private = nullptr; | 366 ui::ContextFactoryPrivate* context_factory_private = nullptr; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 std::set<RootWindowController*> roots = | 415 std::set<RootWindowController*> roots = |
| 409 window_manager_app_->window_manager()->GetRootWindowControllers(); | 416 window_manager_app_->window_manager()->GetRootWindowControllers(); |
| 410 std::vector<RootWindowController*> ordered_roots; | 417 std::vector<RootWindowController*> ordered_roots; |
| 411 ordered_roots.insert(ordered_roots.begin(), roots.begin(), roots.end()); | 418 ordered_roots.insert(ordered_roots.begin(), roots.begin(), roots.end()); |
| 412 std::sort(ordered_roots.begin(), ordered_roots.end(), &CompareByDisplayId); | 419 std::sort(ordered_roots.begin(), ordered_roots.end(), &CompareByDisplayId); |
| 413 return ordered_roots; | 420 return ordered_roots; |
| 414 } | 421 } |
| 415 | 422 |
| 416 } // namespace test | 423 } // namespace test |
| 417 } // namespace ash | 424 } // namespace ash |
| OLD | NEW |