| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/mus/test/wm_test_helper.h" | 5 #include "ash/mus/test/wm_test_helper.h" |
| 6 | 6 |
| 7 #include "ash/mus/screen_mus.h" | 7 #include "ash/mus/screen_mus.h" |
| 8 #include "ash/mus/window_manager.h" | 8 #include "ash/mus/window_manager.h" |
| 9 #include "ash/mus/window_manager_application.h" | 9 #include "ash/mus/window_manager_application.h" |
| 10 #include "ash/public/cpp/config.h" | 10 #include "ash/public/cpp/config.h" |
| 11 #include "ash/test/test_shell_delegate.h" | 11 #include "ash/test/test_shell_delegate.h" |
| 12 #include "ash/wm_window.h" | 12 #include "ash/wm_window.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 17 #include "base/test/sequenced_worker_pool_owner.h" | 17 #include "base/test/sequenced_worker_pool_owner.h" |
| 18 #include "services/ui/public/cpp/input_devices/input_device_client.h" |
| 18 #include "services/ui/public/cpp/property_type_converters.h" | 19 #include "services/ui/public/cpp/property_type_converters.h" |
| 19 #include "ui/aura/mus/window_tree_client.h" | 20 #include "ui/aura/mus/window_tree_client.h" |
| 20 #include "ui/aura/test/env_test_helper.h" | 21 #include "ui/aura/test/env_test_helper.h" |
| 21 #include "ui/aura/test/mus/window_tree_client_private.h" | 22 #include "ui/aura/test/mus/window_tree_client_private.h" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 23 #include "ui/base/material_design/material_design_controller.h" | 24 #include "ui/base/material_design/material_design_controller.h" |
| 24 #include "ui/base/test/material_design_controller_test_api.h" | 25 #include "ui/base/test/material_design_controller_test_api.h" |
| 25 #include "ui/display/display.h" | 26 #include "ui/display/display.h" |
| 26 #include "ui/display/display_list.h" | 27 #include "ui/display/display_list.h" |
| 27 #include "ui/display/screen_base.h" | 28 #include "ui/display/screen_base.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 74 |
| 74 WmTestHelper::~WmTestHelper() { | 75 WmTestHelper::~WmTestHelper() { |
| 75 // Needs to be destroyed before material design. | 76 // Needs to be destroyed before material design. |
| 76 window_manager_app_.reset(); | 77 window_manager_app_.reset(); |
| 77 | 78 |
| 78 base::RunLoop().RunUntilIdle(); | 79 base::RunLoop().RunUntilIdle(); |
| 79 blocking_pool_owner_.reset(); | 80 blocking_pool_owner_.reset(); |
| 80 base::RunLoop().RunUntilIdle(); | 81 base::RunLoop().RunUntilIdle(); |
| 81 | 82 |
| 82 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); | 83 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); |
| 84 |
| 85 input_device_client_.reset(); |
| 83 } | 86 } |
| 84 | 87 |
| 85 void WmTestHelper::Init() { | 88 void WmTestHelper::Init() { |
| 89 const Config config = base::CommandLine::ForCurrentProcess()->HasSwitch("mus") |
| 90 ? Config::MUS |
| 91 : Config::MASH; |
| 92 if (config == Config::MUS) |
| 93 input_device_client_ = base::MakeUnique<ui::InputDeviceClient>(); |
| 94 |
| 86 // MaterialDesignController may have already been initialized. To cover that | 95 // MaterialDesignController may have already been initialized. To cover that |
| 87 // case explicitly uninitialize before initializing. | 96 // case explicitly uninitialize before initializing. |
| 88 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); | 97 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); |
| 89 ui::MaterialDesignController::Initialize(); | 98 ui::MaterialDesignController::Initialize(); |
| 90 | 99 |
| 91 views_delegate_ = base::MakeUnique<views::TestViewsDelegate>(); | 100 views_delegate_ = base::MakeUnique<views::TestViewsDelegate>(); |
| 92 | 101 |
| 93 window_manager_app_ = base::MakeUnique<WindowManagerApplication>(); | 102 window_manager_app_ = base::MakeUnique<WindowManagerApplication>(); |
| 94 | 103 |
| 95 message_loop_.reset(new base::MessageLoopForUI()); | 104 message_loop_.reset(new base::MessageLoopForUI()); |
| 96 | 105 |
| 97 const size_t kMaxNumberThreads = 3u; // Matches that of content. | 106 const size_t kMaxNumberThreads = 3u; // Matches that of content. |
| 98 const char kThreadNamePrefix[] = "MashBlockingForTesting"; | 107 const char kThreadNamePrefix[] = "MashBlockingForTesting"; |
| 99 blocking_pool_owner_ = base::MakeUnique<base::SequencedWorkerPoolOwner>( | 108 blocking_pool_owner_ = base::MakeUnique<base::SequencedWorkerPoolOwner>( |
| 100 kMaxNumberThreads, kThreadNamePrefix); | 109 kMaxNumberThreads, kThreadNamePrefix); |
| 101 | 110 |
| 102 window_manager_app_->window_manager_ = | 111 window_manager_app_->window_manager_ = |
| 103 base::MakeUnique<WindowManager>(nullptr, Config::MASH); | 112 base::MakeUnique<WindowManager>(nullptr, config); |
| 104 window_manager_app_->window_manager()->shell_delegate_ = | 113 window_manager_app_->window_manager()->shell_delegate_ = |
| 105 base::MakeUnique<test::TestShellDelegate>(); | 114 base::MakeUnique<test::TestShellDelegate>(); |
| 106 | 115 |
| 107 window_tree_client_setup_.InitForWindowManager( | 116 window_tree_client_setup_.InitForWindowManager( |
| 108 window_manager_app_->window_manager_.get(), | 117 window_manager_app_->window_manager_.get(), |
| 109 window_manager_app_->window_manager_.get()); | 118 window_manager_app_->window_manager_.get()); |
| 110 aura::test::EnvTestHelper().SetWindowTreeClient( | 119 aura::test::EnvTestHelper().SetWindowTreeClient( |
| 111 window_tree_client_setup_.window_tree_client()); | 120 window_tree_client_setup_.window_tree_client()); |
| 112 // See comment in AshTestHelper for details on why NetworkHandler is not | 121 // See comment in AshTestHelper for details on why NetworkHandler is not |
| 113 // initialized. | 122 // initialized. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 const bool is_primary = | 197 const bool is_primary = |
| 189 screen->display_list().FindDisplayById(updated_display.id()) == | 198 screen->display_list().FindDisplayById(updated_display.id()) == |
| 190 screen->display_list().GetPrimaryDisplayIterator(); | 199 screen->display_list().GetPrimaryDisplayIterator(); |
| 191 screen->display_list().UpdateDisplay( | 200 screen->display_list().UpdateDisplay( |
| 192 updated_display, is_primary ? display::DisplayList::Type::PRIMARY | 201 updated_display, is_primary ? display::DisplayList::Type::PRIMARY |
| 193 : display::DisplayList::Type::NOT_PRIMARY); | 202 : display::DisplayList::Type::NOT_PRIMARY); |
| 194 } | 203 } |
| 195 | 204 |
| 196 } // namespace mus | 205 } // namespace mus |
| 197 } // namespace ash | 206 } // namespace ash |
| OLD | NEW |