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