Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(736)

Side by Side Diff: services/ui/ws/window_server_test_base.cc

Issue 2644093002: aura: Some change to how the client-lib is set up. (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(), nullptr, this,
97 this);
103 window_manager_window_tree_client->ConnectAsWindowManager(); 98 window_manager_window_tree_client->ConnectAsWindowManager();
104 window_manager_ = window_manager_window_tree_client.get(); 99 window_manager_ = window_manager_window_tree_client.get();
105 window_tree_clients_.push_back(std::move(window_manager_window_tree_client)); 100 window_tree_clients_.push_back(std::move(window_manager_window_tree_client));
106 101
107 // Connecting as the WindowManager results in OnWmNewDisplay() being called 102 // 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 103 // 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). 104 // and root window information (otherwise we can't really do anything).
110 ASSERT_TRUE(DoRunLoopWithTimeout()); 105 ASSERT_TRUE(DoRunLoopWithTimeout());
111 } 106 }
112 107
113 void WindowServerTestBase::TearDown() { 108 void WindowServerTestBase::TearDown() {
114 // WindowTreeHost depends on WindowTreeClient. 109 // WindowTreeHost depends on WindowTreeClient.
115 window_tree_hosts_.clear(); 110 window_tree_hosts_.clear();
116 window_tree_clients_.clear(); 111 window_tree_clients_.clear();
117 env_.reset(); 112 env_.reset();
118 gpu_.reset();
119 display::Screen::SetScreenInstance(nullptr); 113 display::Screen::SetScreenInstance(nullptr);
120 114
121 WindowServerServiceTestBase::TearDown(); 115 WindowServerServiceTestBase::TearDown();
122 } 116 }
123 117
124 bool WindowServerTestBase::OnConnect( 118 bool WindowServerTestBase::OnConnect(
125 const service_manager::Identity& remote_identity, 119 const service_manager::Identity& remote_identity,
126 service_manager::InterfaceRegistry* registry) { 120 service_manager::InterfaceRegistry* registry) {
127 registry->AddInterface<mojom::WindowTreeClient>(this); 121 registry->AddInterface<mojom::WindowTreeClient>(this);
128 return true; 122 return true;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 264
271 void WindowServerTestBase::OnWmDeactivateWindow(aura::Window* window) { 265 void WindowServerTestBase::OnWmDeactivateWindow(aura::Window* window) {
272 if (window_manager_delegate_) 266 if (window_manager_delegate_)
273 window_manager_delegate_->OnWmDeactivateWindow(window); 267 window_manager_delegate_->OnWmDeactivateWindow(window);
274 } 268 }
275 269
276 void WindowServerTestBase::Create( 270 void WindowServerTestBase::Create(
277 const service_manager::Identity& remote_identity, 271 const service_manager::Identity& remote_identity,
278 mojom::WindowTreeClientRequest request) { 272 mojom::WindowTreeClientRequest request) {
279 window_tree_clients_.push_back(base::MakeUnique<aura::WindowTreeClient>( 273 window_tree_clients_.push_back(base::MakeUnique<aura::WindowTreeClient>(
280 connector(), this, nullptr, std::move(request))); 274 connector(), nullptr, this, nullptr, std::move(request)));
281 } 275 }
282 276
283 bool WindowServerTestBase::DeleteWindowTreeHost( 277 bool WindowServerTestBase::DeleteWindowTreeHost(
284 aura::WindowTreeHostMus* window_tree_host) { 278 aura::WindowTreeHostMus* window_tree_host) {
285 for (auto iter = window_tree_hosts_.begin(); iter != window_tree_hosts_.end(); 279 for (auto iter = window_tree_hosts_.begin(); iter != window_tree_hosts_.end();
286 ++iter) { 280 ++iter) {
287 if ((*iter).get() == window_tree_host) { 281 if ((*iter).get() == window_tree_host) {
288 window_tree_hosts_.erase(iter); 282 window_tree_hosts_.erase(iter);
289 return true; 283 return true;
290 } 284 }
291 } 285 }
292 return false; 286 return false;
293 } 287 }
294 288
295 } // namespace ui 289 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698