| Index: ash/mus/test/wm_test_helper.cc
|
| diff --git a/ash/mus/test/wm_test_helper.cc b/ash/mus/test/wm_test_helper.cc
|
| index f5cfc7777f579e1737553579bc32472fc94ec9bd..a6d2d52b962cd9a285d7ac08b6632700949e9ca6 100644
|
| --- a/ash/mus/test/wm_test_helper.cc
|
| +++ b/ash/mus/test/wm_test_helper.cc
|
| @@ -8,6 +8,7 @@
|
| #include "ash/mus/window_manager.h"
|
| #include "ash/mus/window_manager_application.h"
|
| #include "ash/public/cpp/config.h"
|
| +#include "ash/shell.h"
|
| #include "ash/test/test_shell_delegate.h"
|
| #include "ash/wm_window.h"
|
| #include "base/memory/ptr_util.h"
|
| @@ -15,6 +16,7 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_split.h"
|
| #include "base/test/sequenced_worker_pool_owner.h"
|
| +#include "services/ui/public/cpp/input_devices/input_device_client.h"
|
| #include "services/ui/public/cpp/property_type_converters.h"
|
| #include "ui/aura/mus/window_tree_client.h"
|
| #include "ui/aura/test/env_test_helper.h"
|
| @@ -25,6 +27,7 @@
|
| #include "ui/display/display.h"
|
| #include "ui/display/display_list.h"
|
| #include "ui/display/screen_base.h"
|
| +#include "ui/display/test/display_manager_test_api.h"
|
| #include "ui/views/test/test_views_delegate.h"
|
|
|
| namespace ash {
|
| @@ -72,6 +75,11 @@ gfx::Rect ParseDisplayBounds(const std::string& spec) {
|
| WmTestHelper::WmTestHelper() {}
|
|
|
| WmTestHelper::~WmTestHelper() {
|
| + // Flush the message loop so that any pending tasks are run. This ensures
|
| + // any delayed tasks, such as deleting RootWindowControllers, are processed
|
| + // before continuing.
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| // Needs to be destroyed before material design.
|
| window_manager_app_.reset();
|
|
|
| @@ -80,9 +88,17 @@ WmTestHelper::~WmTestHelper() {
|
| base::RunLoop().RunUntilIdle();
|
|
|
| ui::test::MaterialDesignControllerTestAPI::Uninitialize();
|
| +
|
| + input_device_client_.reset();
|
| }
|
|
|
| void WmTestHelper::Init() {
|
| + const Config config = base::CommandLine::ForCurrentProcess()->HasSwitch("mus")
|
| + ? Config::MUS
|
| + : Config::MASH;
|
| + if (config == Config::MUS)
|
| + input_device_client_ = base::MakeUnique<ui::InputDeviceClient>();
|
| +
|
| // MaterialDesignController may have already been initialized. To cover that
|
| // case explicitly uninitialize before initializing.
|
| ui::test::MaterialDesignControllerTestAPI::Uninitialize();
|
| @@ -90,7 +106,10 @@ void WmTestHelper::Init() {
|
|
|
| views_delegate_ = base::MakeUnique<views::TestViewsDelegate>();
|
|
|
| - window_manager_app_ = base::MakeUnique<WindowManagerApplication>();
|
| + const bool show_primary_host_on_connect = false;
|
| + window_manager_app_ =
|
| + base::MakeUnique<WindowManagerApplication>(show_primary_host_on_connect,
|
| + config);
|
|
|
| message_loop_.reset(new base::MessageLoopForUI());
|
|
|
| @@ -99,8 +118,8 @@ void WmTestHelper::Init() {
|
| blocking_pool_owner_ = base::MakeUnique<base::SequencedWorkerPoolOwner>(
|
| kMaxNumberThreads, kThreadNamePrefix);
|
|
|
| - window_manager_app_->window_manager_ =
|
| - base::MakeUnique<WindowManager>(nullptr, Config::MASH);
|
| + window_manager_app_->window_manager_ = base::MakeUnique<WindowManager>(
|
| + nullptr, config, show_primary_host_on_connect);
|
| window_manager_app_->window_manager()->shell_delegate_ =
|
| base::MakeUnique<test::TestShellDelegate>();
|
|
|
| @@ -120,8 +139,12 @@ void WmTestHelper::Init() {
|
| window_manager_app_->window_manager()->window_tree_client();
|
| window_tree_client_private_ =
|
| base::MakeUnique<aura::WindowTreeClientPrivate>(window_tree_client);
|
| - int next_x = 0;
|
| - CreateRootWindowController("800x600", &next_x);
|
| + if (config == Config::MUS) {
|
| + window_tree_client_private_->CallOnConnect();
|
| + } else {
|
| + int next_x = 0;
|
| + CreateRootWindowController("800x600", &next_x);
|
| + }
|
| }
|
|
|
| std::vector<RootWindowController*> WmTestHelper::GetRootsOrderedByDisplayId() {
|
| @@ -134,6 +157,11 @@ std::vector<RootWindowController*> WmTestHelper::GetRootsOrderedByDisplayId() {
|
| }
|
|
|
| void WmTestHelper::UpdateDisplay(const std::string& display_spec) {
|
| + if (Shell::GetAshConfig() == Config::MUS) {
|
| + display::test::DisplayManagerTestApi(Shell::Get()->display_manager())
|
| + .UpdateDisplay(display_spec);
|
| + return;
|
| + }
|
| const std::vector<std::string> parts = base::SplitString(
|
| display_spec, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
| std::vector<RootWindowController*> root_window_controllers =
|
|
|