| 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/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/test/material_design_controller_test_api.h" | 8 #include "ash/common/test/material_design_controller_test_api.h" |
| 9 #include "ash/mus/root_window_controller.h" | 9 #include "ash/mus/root_window_controller.h" |
| 10 #include "ash/mus/test/wm_test_screen.h" | 10 #include "ash/mus/test/wm_test_screen.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace ash { | 22 namespace ash { |
| 23 namespace mus { | 23 namespace mus { |
| 24 | 24 |
| 25 WmTestHelper::WmTestHelper() {} | 25 WmTestHelper::WmTestHelper() {} |
| 26 | 26 |
| 27 WmTestHelper::~WmTestHelper() { | 27 WmTestHelper::~WmTestHelper() { |
| 28 // Needs to be destroyed before material design. | 28 // Needs to be destroyed before material design. |
| 29 window_manager_app_.reset(); | 29 window_manager_app_.reset(); |
| 30 | 30 |
| 31 base::RunLoop().RunUntilIdle(); |
| 32 blocking_pool_owner_.reset(); |
| 33 base::RunLoop().RunUntilIdle(); |
| 34 |
| 31 ash::test::MaterialDesignControllerTestAPI::Uninitialize(); | 35 ash::test::MaterialDesignControllerTestAPI::Uninitialize(); |
| 32 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); | 36 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); |
| 33 } | 37 } |
| 34 | 38 |
| 35 void WmTestHelper::Init() { | 39 void WmTestHelper::Init() { |
| 36 ui::MaterialDesignController::Initialize(); | 40 ui::MaterialDesignController::Initialize(); |
| 37 ash::MaterialDesignController::Initialize(); | 41 ash::MaterialDesignController::Initialize(); |
| 38 | 42 |
| 39 window_manager_app_ = base::MakeUnique<WindowManagerApplication>(); | 43 window_manager_app_ = base::MakeUnique<WindowManagerApplication>(); |
| 40 | 44 |
| 41 message_loop_.reset(new base::MessageLoopForUI()); | 45 message_loop_.reset(new base::MessageLoopForUI()); |
| 46 |
| 47 const size_t kMaxNumberThreads = 3u; // Matches that of content. |
| 48 const char kThreadNamePrefix[] = "MashBlockingForTesting"; |
| 49 blocking_pool_owner_ = base::MakeUnique<base::SequencedWorkerPoolOwner>( |
| 50 kMaxNumberThreads, kThreadNamePrefix); |
| 51 |
| 42 window_manager_app_->window_manager_.reset(new WindowManager(nullptr)); | 52 window_manager_app_->window_manager_.reset(new WindowManager(nullptr)); |
| 43 screen_ = new WmTestScreen; | 53 screen_ = new WmTestScreen; |
| 44 window_manager_app_->window_manager_->screen_.reset(screen_); | 54 window_manager_app_->window_manager_->screen_.reset(screen_); |
| 45 | 55 |
| 46 // Need an id other than kInvalidDisplayID so the Display is considered valid. | 56 // Need an id other than kInvalidDisplayID so the Display is considered valid. |
| 47 display::Display display(1); | 57 display::Display display(1); |
| 48 const gfx::Rect display_bounds(0, 0, 800, 600); | 58 const gfx::Rect display_bounds(0, 0, 800, 600); |
| 49 display.set_bounds(display_bounds); | 59 display.set_bounds(display_bounds); |
| 50 // Offset the height slightly to give a different work area. -20 is arbitrary, | 60 // Offset the height slightly to give a different work area. -20 is arbitrary, |
| 51 // it could be anything. | 61 // it could be anything. |
| 52 const gfx::Rect work_area(0, 0, display_bounds.width(), | 62 const gfx::Rect work_area(0, 0, display_bounds.width(), |
| 53 display_bounds.height() - 20); | 63 display_bounds.height() - 20); |
| 54 display.set_work_area(work_area); | 64 display.set_work_area(work_area); |
| 55 window_tree_client_setup_.InitForWindowManager( | 65 window_tree_client_setup_.InitForWindowManager( |
| 56 window_manager_app_->window_manager_.get(), | 66 window_manager_app_->window_manager_.get(), |
| 57 window_manager_app_->window_manager_.get(), display); | 67 window_manager_app_->window_manager_.get(), display); |
| 58 | 68 |
| 59 window_manager_app_->InitWindowManager( | 69 window_manager_app_->InitWindowManager( |
| 60 window_tree_client_setup_.OwnWindowTreeClient()); | 70 window_tree_client_setup_.OwnWindowTreeClient(), |
| 71 blocking_pool_owner_->pool()); |
| 61 ui::WindowTreeClient* window_tree_client = | 72 ui::WindowTreeClient* window_tree_client = |
| 62 window_manager_app_->window_manager()->window_tree_client(); | 73 window_manager_app_->window_manager()->window_tree_client(); |
| 63 | 74 |
| 64 screen_->display_list()->AddDisplay(display, | 75 screen_->display_list()->AddDisplay(display, |
| 65 display::DisplayList::Type::PRIMARY); | 76 display::DisplayList::Type::PRIMARY); |
| 66 | 77 |
| 67 ui::WindowTreeClientPrivate(window_tree_client) | 78 ui::WindowTreeClientPrivate(window_tree_client) |
| 68 .CallWmNewDisplayAdded(display); | 79 .CallWmNewDisplayAdded(display); |
| 69 } | 80 } |
| 70 | 81 |
| 71 } // namespace mus | 82 } // namespace mus |
| 72 } // namespace ash | 83 } // namespace ash |
| OLD | NEW |