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

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

Issue 2795883002: Eliminate OnConnect usage (Closed)
Patch Set: . Created 3 years, 8 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
« no previous file with comments | « services/ui/ws/window_server_test_base.h ('k') | services/ui/ws/window_tree_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
16 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
17 #include "ui/aura/mus/window_tree_client.h" 16 #include "ui/aura/mus/window_tree_client.h"
18 #include "ui/aura/mus/window_tree_host_mus.h" 17 #include "ui/aura/mus/window_tree_host_mus.h"
19 #include "ui/display/display.h" 18 #include "ui/display/display.h"
20 #include "ui/display/display_list.h" 19 #include "ui/display/display_list.h"
21 #include "ui/wm/core/capture_controller.h" 20 #include "ui/wm/core/capture_controller.h"
22 21
23 namespace ui { 22 namespace ui {
24 namespace { 23 namespace {
25 24
26 base::RunLoop* current_run_loop = nullptr; 25 base::RunLoop* current_run_loop = nullptr;
27 26
28 void TimeoutRunLoop(const base::Closure& timeout_task, bool* timeout) { 27 void TimeoutRunLoop(const base::Closure& timeout_task, bool* timeout) {
29 CHECK(current_run_loop); 28 CHECK(current_run_loop);
30 *timeout = true; 29 *timeout = true;
31 timeout_task.Run(); 30 timeout_task.Run();
32 } 31 }
33 32
34 } // namespace 33 } // namespace
35 34
36 WindowServerTestBase::WindowServerTestBase() {} 35 WindowServerTestBase::WindowServerTestBase() {
36 registry_.AddInterface<mojom::WindowTreeClient>(this);
37 }
37 38
38 WindowServerTestBase::~WindowServerTestBase() {} 39 WindowServerTestBase::~WindowServerTestBase() {}
39 40
40 // static 41 // static
41 bool WindowServerTestBase::DoRunLoopWithTimeout() { 42 bool WindowServerTestBase::DoRunLoopWithTimeout() {
42 if (current_run_loop != nullptr) 43 if (current_run_loop != nullptr)
43 return false; 44 return false;
44 45
45 bool timeout = false; 46 bool timeout = false;
46 base::RunLoop run_loop; 47 base::RunLoop run_loop;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 void WindowServerTestBase::TearDown() { 108 void WindowServerTestBase::TearDown() {
108 // WindowTreeHost depends on WindowTreeClient. 109 // WindowTreeHost depends on WindowTreeClient.
109 window_tree_hosts_.clear(); 110 window_tree_hosts_.clear();
110 window_tree_clients_.clear(); 111 window_tree_clients_.clear();
111 env_.reset(); 112 env_.reset();
112 display::Screen::SetScreenInstance(nullptr); 113 display::Screen::SetScreenInstance(nullptr);
113 114
114 WindowServerServiceTestBase::TearDown(); 115 WindowServerServiceTestBase::TearDown();
115 } 116 }
116 117
117 bool WindowServerTestBase::OnConnect( 118 void WindowServerTestBase::OnBindInterface(
118 const service_manager::Identity& remote_identity, 119 const service_manager::ServiceInfo& source_info,
119 service_manager::InterfaceRegistry* registry) { 120 const std::string& interface_name,
120 registry->AddInterface<mojom::WindowTreeClient>(this); 121 mojo::ScopedMessagePipeHandle interface_pipe) {
121 return true; 122 registry_.BindInterface(source_info.identity, interface_name,
123 std::move(interface_pipe));
122 } 124 }
123 125
124 void WindowServerTestBase::OnEmbed( 126 void WindowServerTestBase::OnEmbed(
125 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { 127 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
126 EXPECT_TRUE(QuitRunLoop()); 128 EXPECT_TRUE(QuitRunLoop());
127 window_tree_hosts_.push_back(std::move(window_tree_host)); 129 window_tree_hosts_.push_back(std::move(window_tree_host));
128 } 130 }
129 131
130 void WindowServerTestBase::OnLostConnection(aura::WindowTreeClient* client) { 132 void WindowServerTestBase::OnLostConnection(aura::WindowTreeClient* client) {
131 window_tree_client_lost_connection_ = true; 133 window_tree_client_lost_connection_ = true;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 ++iter) { 292 ++iter) {
291 if ((*iter).get() == window_tree_host) { 293 if ((*iter).get() == window_tree_host) {
292 window_tree_hosts_.erase(iter); 294 window_tree_hosts_.erase(iter);
293 return true; 295 return true;
294 } 296 }
295 } 297 }
296 return false; 298 return false;
297 } 299 }
298 300
299 } // namespace ui 301 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_server_test_base.h ('k') | services/ui/ws/window_tree_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698