| 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/root_window_controller.h" | 7 #include "ash/mus/root_window_controller.h" |
| 8 #include "ash/mus/test/wm_test_screen.h" | 8 #include "ash/mus/test/wm_test_screen.h" |
| 9 #include "ash/mus/window_manager.h" | 9 #include "ash/mus/window_manager.h" |
| 10 #include "ash/mus/window_manager_application.h" | 10 #include "ash/mus/window_manager_application.h" |
| 11 #include "base/memory/ptr_util.h" |
| 11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 12 #include "components/mus/public/cpp/property_type_converters.h" | 13 #include "components/mus/public/cpp/property_type_converters.h" |
| 14 #include "components/mus/public/cpp/tests/window_tree_client_private.h" |
| 13 #include "components/mus/public/cpp/window_tree_client.h" | 15 #include "components/mus/public/cpp/window_tree_client.h" |
| 14 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
| 15 | 17 |
| 16 namespace ash { | 18 namespace ash { |
| 17 namespace mus { | 19 namespace mus { |
| 18 | 20 |
| 19 WmTestHelper::WmTestHelper() {} | 21 WmTestHelper::WmTestHelper() {} |
| 20 | 22 |
| 21 WmTestHelper::~WmTestHelper() {} | 23 WmTestHelper::~WmTestHelper() {} |
| 22 | 24 |
| 23 void WmTestHelper::Init() { | 25 void WmTestHelper::Init() { |
| 24 message_loop_.reset(new base::MessageLoopForUI()); | 26 message_loop_.reset(new base::MessageLoopForUI()); |
| 25 const uint32_t app_id = 1; | 27 window_manager_app_.window_manager_.reset( |
| 26 window_manager_app_.Initialize(nullptr, shell::Identity(), app_id); | 28 new WindowManager(&window_manager_app_, nullptr)); |
| 27 screen_ = new WmTestScreen; | 29 screen_ = new WmTestScreen; |
| 28 window_manager_app_.screen_.reset(screen_); | 30 window_manager_app_.window_manager_->screen_.reset(screen_); |
| 29 | 31 |
| 30 // RootWindowController controls its own lifetime. | |
| 31 RootWindowController* root_window_controller = | |
| 32 new RootWindowController(&window_manager_app_); | |
| 33 // Need an id other than kInvalidDisplayID so the Display is considered valid. | 32 // Need an id other than kInvalidDisplayID so the Display is considered valid. |
| 34 root_window_controller->display_.set_id(1); | 33 display::Display display(1); |
| 35 const gfx::Rect display_bounds(0, 0, 800, 600); | 34 const gfx::Rect display_bounds(0, 0, 800, 600); |
| 36 root_window_controller->display_.set_bounds(display_bounds); | 35 display.set_bounds(display_bounds); |
| 37 // Offset the height slightly to give a different work area. -20 is arbitrary, | 36 // Offset the height slightly to give a different work area. -20 is arbitrary, |
| 38 // it could be anything. | 37 // it could be anything. |
| 39 const gfx::Rect work_area(0, 0, display_bounds.width(), | 38 const gfx::Rect work_area(0, 0, display_bounds.width(), |
| 40 display_bounds.height() - 20); | 39 display_bounds.height() - 20); |
| 41 root_window_controller->display_.set_work_area(work_area); | 40 display.set_work_area(work_area); |
| 41 window_tree_client_setup_.InitForWindowManager( |
| 42 window_manager_app_.window_manager_.get(), |
| 43 window_manager_app_.window_manager_.get(), display); |
| 42 | 44 |
| 43 screen_->display_list()->AddDisplay(root_window_controller->display(), | 45 window_manager_app_.InitWindowManager( |
| 46 window_tree_client_setup_.window_tree_client()); |
| 47 |
| 48 screen_->display_list()->AddDisplay(display, |
| 44 views::DisplayList::Type::PRIMARY); | 49 views::DisplayList::Type::PRIMARY); |
| 45 | 50 |
| 46 window_tree_client_setup_.Init(root_window_controller, | 51 ::mus::WindowTreeClientPrivate(window_tree_client_setup_.window_tree_client()) |
| 47 root_window_controller->window_manager_.get()); | 52 .CallWmNewDisplayAdded(display); |
| 48 root_window_controller->root()->SetBounds(display_bounds); | |
| 49 window_manager_app_.AddRootWindowController(root_window_controller); | |
| 50 } | 53 } |
| 51 | 54 |
| 52 } // namespace mus | 55 } // namespace mus |
| 53 } // namespace ash | 56 } // namespace ash |
| OLD | NEW |