| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/ui/ws/window_server_test_base.h" | 5 #include "services/ui/ws/window_server_test_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "services/service_manager/public/cpp/connector.h" | 14 #include "services/service_manager/public/cpp/connector.h" |
| 15 #include "services/service_manager/public/cpp/interface_registry.h" | 15 #include "services/service_manager/public/cpp/interface_registry.h" |
| 16 #include "services/ui/public/cpp/gpu/gpu.h" | |
| 17 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
| 18 #include "ui/aura/mus/mus_context_factory.h" | |
| 19 #include "ui/aura/mus/window_tree_client.h" | 17 #include "ui/aura/mus/window_tree_client.h" |
| 20 #include "ui/aura/mus/window_tree_host_mus.h" | 18 #include "ui/aura/mus/window_tree_host_mus.h" |
| 21 #include "ui/display/display.h" | 19 #include "ui/display/display.h" |
| 22 #include "ui/display/display_list.h" | 20 #include "ui/display/display_list.h" |
| 23 #include "ui/wm/core/capture_controller.h" | 21 #include "ui/wm/core/capture_controller.h" |
| 24 | 22 |
| 25 namespace ui { | 23 namespace ui { |
| 26 namespace { | 24 namespace { |
| 27 | 25 |
| 28 base::RunLoop* current_run_loop = nullptr; | 26 base::RunLoop* current_run_loop = nullptr; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 std::unique_ptr<aura::WindowTreeClient> result = | 84 std::unique_ptr<aura::WindowTreeClient> result = |
| 87 std::move(window_tree_clients_.back()); | 85 std::move(window_tree_clients_.back()); |
| 88 window_tree_clients_.pop_back(); | 86 window_tree_clients_.pop_back(); |
| 89 return result; | 87 return result; |
| 90 } | 88 } |
| 91 | 89 |
| 92 void WindowServerTestBase::SetUp() { | 90 void WindowServerTestBase::SetUp() { |
| 93 WindowServerServiceTestBase::SetUp(); | 91 WindowServerServiceTestBase::SetUp(); |
| 94 | 92 |
| 95 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); | 93 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); |
| 96 gpu_ = ui::Gpu::Create(connector(), nullptr); | |
| 97 compositor_context_factory_ = | |
| 98 base::MakeUnique<aura::MusContextFactory>(gpu_.get()); | |
| 99 env_->set_context_factory(compositor_context_factory_.get()); | |
| 100 display::Screen::SetScreenInstance(&screen_); | 94 display::Screen::SetScreenInstance(&screen_); |
| 101 std::unique_ptr<aura::WindowTreeClient> window_manager_window_tree_client = | 95 std::unique_ptr<aura::WindowTreeClient> window_manager_window_tree_client = |
| 102 base::MakeUnique<aura::WindowTreeClient>(connector(), this, this); | 96 base::MakeUnique<aura::WindowTreeClient>(connector(), this, this); |
| 103 window_manager_window_tree_client->ConnectAsWindowManager(); | 97 window_manager_window_tree_client->ConnectAsWindowManager(); |
| 104 window_manager_ = window_manager_window_tree_client.get(); | 98 window_manager_ = window_manager_window_tree_client.get(); |
| 105 window_tree_clients_.push_back(std::move(window_manager_window_tree_client)); | 99 window_tree_clients_.push_back(std::move(window_manager_window_tree_client)); |
| 106 | 100 |
| 107 // Connecting as the WindowManager results in OnWmNewDisplay() being called | 101 // Connecting as the WindowManager results in OnWmNewDisplay() being called |
| 108 // with the display (and root). Wait for it to be called so we have display | 102 // with the display (and root). Wait for it to be called so we have display |
| 109 // and root window information (otherwise we can't really do anything). | 103 // and root window information (otherwise we can't really do anything). |
| 110 ASSERT_TRUE(DoRunLoopWithTimeout()); | 104 ASSERT_TRUE(DoRunLoopWithTimeout()); |
| 111 } | 105 } |
| 112 | 106 |
| 113 void WindowServerTestBase::TearDown() { | 107 void WindowServerTestBase::TearDown() { |
| 114 // WindowTreeHost depends on WindowTreeClient. | 108 // WindowTreeHost depends on WindowTreeClient. |
| 115 window_tree_hosts_.clear(); | 109 window_tree_hosts_.clear(); |
| 116 window_tree_clients_.clear(); | 110 window_tree_clients_.clear(); |
| 117 env_.reset(); | 111 env_.reset(); |
| 118 gpu_.reset(); | |
| 119 display::Screen::SetScreenInstance(nullptr); | 112 display::Screen::SetScreenInstance(nullptr); |
| 120 | 113 |
| 121 WindowServerServiceTestBase::TearDown(); | 114 WindowServerServiceTestBase::TearDown(); |
| 122 } | 115 } |
| 123 | 116 |
| 124 bool WindowServerTestBase::OnConnect( | 117 bool WindowServerTestBase::OnConnect( |
| 125 const service_manager::Identity& remote_identity, | 118 const service_manager::Identity& remote_identity, |
| 126 service_manager::InterfaceRegistry* registry) { | 119 service_manager::InterfaceRegistry* registry) { |
| 127 registry->AddInterface<mojom::WindowTreeClient>(this); | 120 registry->AddInterface<mojom::WindowTreeClient>(this); |
| 128 return true; | 121 return true; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 ++iter) { | 279 ++iter) { |
| 287 if ((*iter).get() == window_tree_host) { | 280 if ((*iter).get() == window_tree_host) { |
| 288 window_tree_hosts_.erase(iter); | 281 window_tree_hosts_.erase(iter); |
| 289 return true; | 282 return true; |
| 290 } | 283 } |
| 291 } | 284 } |
| 292 return false; | 285 return false; |
| 293 } | 286 } |
| 294 | 287 |
| 295 } // namespace ui | 288 } // namespace ui |
| OLD | NEW |