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_service.h" | 16 #include "services/ui/public/cpp/gpu/gpu.h" |
17 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
18 #include "ui/aura/mus/mus_context_factory.h" | 18 #include "ui/aura/mus/mus_context_factory.h" |
19 #include "ui/aura/mus/window_tree_client.h" | 19 #include "ui/aura/mus/window_tree_client.h" |
20 #include "ui/aura/mus/window_tree_host_mus.h" | 20 #include "ui/aura/mus/window_tree_host_mus.h" |
21 #include "ui/display/display.h" | 21 #include "ui/display/display.h" |
22 #include "ui/display/display_list.h" | 22 #include "ui/display/display_list.h" |
23 #include "ui/wm/core/capture_controller.h" | 23 #include "ui/wm/core/capture_controller.h" |
24 | 24 |
25 namespace ui { | 25 namespace ui { |
26 namespace { | 26 namespace { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 std::unique_ptr<aura::WindowTreeClient> result = | 86 std::unique_ptr<aura::WindowTreeClient> result = |
87 std::move(window_tree_clients_.back()); | 87 std::move(window_tree_clients_.back()); |
88 window_tree_clients_.pop_back(); | 88 window_tree_clients_.pop_back(); |
89 return result; | 89 return result; |
90 } | 90 } |
91 | 91 |
92 void WindowServerTestBase::SetUp() { | 92 void WindowServerTestBase::SetUp() { |
93 WindowServerServiceTestBase::SetUp(); | 93 WindowServerServiceTestBase::SetUp(); |
94 | 94 |
95 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); | 95 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); |
96 gpu_service_ = ui::GpuService::Create(connector(), nullptr); | 96 gpu_ = ui::Gpu::Create(connector(), nullptr); |
97 compositor_context_factory_ = | 97 compositor_context_factory_ = |
98 base::MakeUnique<aura::MusContextFactory>(gpu_service_.get()); | 98 base::MakeUnique<aura::MusContextFactory>(gpu_.get()); |
99 env_->set_context_factory(compositor_context_factory_.get()); | 99 env_->set_context_factory(compositor_context_factory_.get()); |
100 display::Screen::SetScreenInstance(&screen_); | 100 display::Screen::SetScreenInstance(&screen_); |
101 std::unique_ptr<aura::WindowTreeClient> window_manager_window_tree_client = | 101 std::unique_ptr<aura::WindowTreeClient> window_manager_window_tree_client = |
102 base::MakeUnique<aura::WindowTreeClient>(connector(), this, this); | 102 base::MakeUnique<aura::WindowTreeClient>(connector(), this, this); |
103 window_manager_window_tree_client->ConnectAsWindowManager(); | 103 window_manager_window_tree_client->ConnectAsWindowManager(); |
104 window_manager_ = window_manager_window_tree_client.get(); | 104 window_manager_ = window_manager_window_tree_client.get(); |
105 window_tree_clients_.push_back(std::move(window_manager_window_tree_client)); | 105 window_tree_clients_.push_back(std::move(window_manager_window_tree_client)); |
106 | 106 |
107 // Connecting as the WindowManager results in OnWmNewDisplay() being called | 107 // 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 | 108 // 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). | 109 // and root window information (otherwise we can't really do anything). |
110 ASSERT_TRUE(DoRunLoopWithTimeout()); | 110 ASSERT_TRUE(DoRunLoopWithTimeout()); |
111 } | 111 } |
112 | 112 |
113 void WindowServerTestBase::TearDown() { | 113 void WindowServerTestBase::TearDown() { |
114 // WindowTreeHost depends on WindowTreeClient. | 114 // WindowTreeHost depends on WindowTreeClient. |
115 window_tree_hosts_.clear(); | 115 window_tree_hosts_.clear(); |
116 window_tree_clients_.clear(); | 116 window_tree_clients_.clear(); |
117 env_.reset(); | 117 env_.reset(); |
118 gpu_service_.reset(); | 118 gpu_.reset(); |
119 display::Screen::SetScreenInstance(nullptr); | 119 display::Screen::SetScreenInstance(nullptr); |
120 | 120 |
121 WindowServerServiceTestBase::TearDown(); | 121 WindowServerServiceTestBase::TearDown(); |
122 } | 122 } |
123 | 123 |
124 bool WindowServerTestBase::OnConnect( | 124 bool WindowServerTestBase::OnConnect( |
125 const service_manager::Identity& remote_identity, | 125 const service_manager::Identity& remote_identity, |
126 service_manager::InterfaceRegistry* registry) { | 126 service_manager::InterfaceRegistry* registry) { |
127 registry->AddInterface<mojom::WindowTreeClient>(this); | 127 registry->AddInterface<mojom::WindowTreeClient>(this); |
128 return true; | 128 return true; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 ++iter) { | 275 ++iter) { |
276 if ((*iter).get() == window_tree_host) { | 276 if ((*iter).get() == window_tree_host) { |
277 window_tree_hosts_.erase(iter); | 277 window_tree_hosts_.erase(iter); |
278 return true; | 278 return true; |
279 } | 279 } |
280 } | 280 } |
281 return false; | 281 return false; |
282 } | 282 } |
283 | 283 |
284 } // namespace ui | 284 } // namespace ui |
OLD | NEW |