| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 device::BluetoothAdapterFactory::Shutdown(); | 209 device::BluetoothAdapterFactory::Shutdown(); |
| 210 bluez::BluezDBusManager::Shutdown(); | 210 bluez::BluezDBusManager::Shutdown(); |
| 211 bluez_dbus_manager_initialized_ = false; | 211 bluez_dbus_manager_initialized_ = false; |
| 212 } | 212 } |
| 213 | 213 |
| 214 if (dbus_thread_manager_initialized_) { | 214 if (dbus_thread_manager_initialized_) { |
| 215 chromeos::DBusThreadManager::Shutdown(); | 215 chromeos::DBusThreadManager::Shutdown(); |
| 216 dbus_thread_manager_initialized_ = false; | 216 dbus_thread_manager_initialized_ = false; |
| 217 } | 217 } |
| 218 | 218 |
| 219 ui::TerminateContextFactoryForTests(); | 219 if (config_ == Config::CLASSIC) |
| 220 ui::TerminateContextFactoryForTests(); |
| 220 | 221 |
| 221 ui::ShutdownInputMethodForTesting(); | 222 ui::ShutdownInputMethodForTesting(); |
| 222 zero_duration_mode_.reset(); | 223 zero_duration_mode_.reset(); |
| 223 | 224 |
| 224 test_views_delegate_.reset(); | 225 test_views_delegate_.reset(); |
| 225 wm_state_.reset(); | 226 wm_state_.reset(); |
| 226 | 227 |
| 227 input_device_client_.reset(); | 228 input_device_client_.reset(); |
| 228 | 229 |
| 229 // WindowManager owns the CaptureController for mus/mash. | 230 // WindowManager owns the CaptureController for mus/mash. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 276 } |
| 276 const bool in_shutdown = false; | 277 const bool in_shutdown = false; |
| 277 while (root_window_controllers.size() > parts.size()) { | 278 while (root_window_controllers.size() > parts.size()) { |
| 278 window_manager_app_->window_manager()->DestroyRootWindowController( | 279 window_manager_app_->window_manager()->DestroyRootWindowController( |
| 279 root_window_controllers.back(), in_shutdown); | 280 root_window_controllers.back(), in_shutdown); |
| 280 root_window_controllers.pop_back(); | 281 root_window_controllers.pop_back(); |
| 281 } | 282 } |
| 282 } | 283 } |
| 283 | 284 |
| 284 display::Display AshTestHelper::GetSecondaryDisplay() { | 285 display::Display AshTestHelper::GetSecondaryDisplay() { |
| 285 if (config_ == Config::CLASSIC) | 286 if (config_ != Config::MASH) |
| 286 return Shell::Get()->display_manager()->GetSecondaryDisplay(); | 287 return Shell::Get()->display_manager()->GetSecondaryDisplay(); |
| 287 | 288 |
| 288 std::vector<RootWindowController*> roots = GetRootsOrderedByDisplayId(); | 289 std::vector<RootWindowController*> roots = GetRootsOrderedByDisplayId(); |
| 289 CHECK_LE(2U, roots.size()); | 290 CHECK_LE(2U, roots.size()); |
| 290 return roots.size() < 2 ? display::Display() | 291 return roots.size() < 2 ? display::Display() |
| 291 : roots[1]->GetWindow()->GetDisplayNearestWindow(); | 292 : roots[1]->GetWindow()->GetDisplayNearestWindow(); |
| 292 } | 293 } |
| 293 | 294 |
| 294 void AshTestHelper::CreateMashWindowManager() { | 295 void AshTestHelper::CreateMashWindowManager() { |
| 295 CHECK(config_ != Config::CLASSIC); | 296 CHECK(config_ != Config::CLASSIC); |
| 296 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); |
| 297 | 300 |
| 298 window_manager_app_->window_manager_.reset( | 301 window_manager_app_->window_manager_.reset( |
| 299 new mus::WindowManager(nullptr, config_)); | 302 new mus::WindowManager(nullptr, config_, show_primary_root_on_connect)); |
| 300 window_manager_app_->window_manager()->shell_delegate_.reset( | 303 window_manager_app_->window_manager()->shell_delegate_.reset( |
| 301 test_shell_delegate_); | 304 test_shell_delegate_); |
| 302 window_manager_app_->window_manager() | 305 window_manager_app_->window_manager() |
| 303 ->create_session_state_delegate_stub_for_test_ = false; | 306 ->create_session_state_delegate_stub_for_test_ = false; |
| 304 | 307 |
| 305 window_tree_client_setup_.InitForWindowManager( | 308 window_tree_client_setup_.InitForWindowManager( |
| 306 window_manager_app_->window_manager_.get(), | 309 window_manager_app_->window_manager_.get(), |
| 307 window_manager_app_->window_manager_.get()); | 310 window_manager_app_->window_manager_.get()); |
| 308 aura::test::EnvTestHelper().SetWindowTreeClient( | 311 aura::test::EnvTestHelper().SetWindowTreeClient( |
| 309 window_tree_client_setup_.window_tree_client()); | 312 window_tree_client_setup_.window_tree_client()); |
| 310 // 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 |
| 311 // 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 |
| 312 // additional tray items) that can make for flaky tests. | 315 // additional tray items) that can make for flaky tests. |
| 313 const bool init_network_handler = false; | 316 const bool init_network_handler = false; |
| 314 window_manager_app_->InitWindowManager( | 317 window_manager_app_->InitWindowManager( |
| 315 window_tree_client_setup_.OwnWindowTreeClient(), | 318 window_tree_client_setup_.OwnWindowTreeClient(), |
| 316 ash_test_environment_->GetBlockingPool(), init_network_handler); | 319 ash_test_environment_->GetBlockingPool(), init_network_handler); |
| 317 | 320 |
| 318 aura::WindowTreeClient* window_tree_client = | 321 aura::WindowTreeClient* window_tree_client = |
| 319 window_manager_app_->window_manager()->window_tree_client(); | 322 window_manager_app_->window_manager()->window_tree_client(); |
| 320 window_tree_client_private_ = | 323 window_tree_client_private_ = |
| 321 base::MakeUnique<aura::WindowTreeClientPrivate>(window_tree_client); | 324 base::MakeUnique<aura::WindowTreeClientPrivate>(window_tree_client); |
| 322 int next_x = 0; | 325 if (config_ == Config::MUS) { |
| 323 CreateRootWindowController("800x600", &next_x); | 326 window_tree_client_private_->CallOnConnect(); |
| 327 } else { |
| 328 int next_x = 0; |
| 329 CreateRootWindowController("800x600", &next_x); |
| 330 } |
| 324 | 331 |
| 325 // 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 |
| 326 // why the NetworkHandler should not be running. | 333 // why the NetworkHandler should not be running. |
| 327 CHECK(!chromeos::NetworkHandler::IsInitialized()); | 334 CHECK(!chromeos::NetworkHandler::IsInitialized()); |
| 328 } | 335 } |
| 329 | 336 |
| 330 void AshTestHelper::CreateShell() { | 337 void AshTestHelper::CreateShell() { |
| 331 CHECK(config_ == Config::CLASSIC); | 338 CHECK(config_ == Config::CLASSIC); |
| 332 ui::ContextFactory* context_factory = nullptr; | 339 ui::ContextFactory* context_factory = nullptr; |
| 333 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... |
| 382 std::set<RootWindowController*> roots = | 389 std::set<RootWindowController*> roots = |
| 383 window_manager_app_->window_manager()->GetRootWindowControllers(); | 390 window_manager_app_->window_manager()->GetRootWindowControllers(); |
| 384 std::vector<RootWindowController*> ordered_roots; | 391 std::vector<RootWindowController*> ordered_roots; |
| 385 ordered_roots.insert(ordered_roots.begin(), roots.begin(), roots.end()); | 392 ordered_roots.insert(ordered_roots.begin(), roots.begin(), roots.end()); |
| 386 std::sort(ordered_roots.begin(), ordered_roots.end(), &CompareByDisplayId); | 393 std::sort(ordered_roots.begin(), ordered_roots.end(), &CompareByDisplayId); |
| 387 return ordered_roots; | 394 return ordered_roots; |
| 388 } | 395 } |
| 389 | 396 |
| 390 } // namespace test | 397 } // namespace test |
| 391 } // namespace ash | 398 } // namespace ash |
| OLD | NEW |