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

Side by Side Diff: components/mus/public/cpp/tests/window_server_test_base.cc

Issue 2018823002: Eliminate WindowTreeConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@connection
Patch Set: . Created 4 years, 6 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 "components/mus/public/cpp/tests/window_server_test_base.h" 5 #include "components/mus/public/cpp/tests/window_server_test_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
11 #include "components/mus/public/cpp/window.h" 11 #include "components/mus/public/cpp/window.h"
12 #include "components/mus/public/cpp/window_tree_connection.h" 12 #include "components/mus/public/cpp/window_tree_client.h"
13 #include "components/mus/public/cpp/window_tree_host_factory.h" 13 #include "components/mus/public/cpp/window_tree_host_factory.h"
14 #include "services/shell/public/cpp/connector.h" 14 #include "services/shell/public/cpp/connector.h"
15 15
16 namespace mus { 16 namespace mus {
17 namespace { 17 namespace {
18 18
19 base::RunLoop* current_run_loop = nullptr; 19 base::RunLoop* current_run_loop = nullptr;
20 20
21 void TimeoutRunLoop(const base::Closure& timeout_task, bool* timeout) { 21 void TimeoutRunLoop(const base::Closure& timeout_task, bool* timeout) {
22 CHECK(current_run_loop); 22 CHECK(current_run_loop);
23 *timeout = true; 23 *timeout = true;
24 timeout_task.Run(); 24 timeout_task.Run();
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 WindowServerTestBase::WindowServerTestBase() 29 WindowServerTestBase::WindowServerTestBase()
30 : most_recent_connection_(nullptr), 30 : most_recent_client_(nullptr),
31 window_manager_(nullptr), 31 window_manager_(nullptr),
32 window_manager_delegate_(nullptr), 32 window_manager_delegate_(nullptr),
33 window_manager_client_(nullptr), 33 window_manager_client_(nullptr),
34 window_tree_connection_destroyed_(false) {} 34 window_tree_client_destroyed_(false) {}
35 35
36 WindowServerTestBase::~WindowServerTestBase() {} 36 WindowServerTestBase::~WindowServerTestBase() {}
37 37
38 // static 38 // static
39 bool WindowServerTestBase::DoRunLoopWithTimeout() { 39 bool WindowServerTestBase::DoRunLoopWithTimeout() {
40 if (current_run_loop != nullptr) 40 if (current_run_loop != nullptr)
41 return false; 41 return false;
42 42
43 bool timeout = false; 43 bool timeout = false;
44 base::RunLoop run_loop; 44 base::RunLoop run_loop;
(...skipping 16 matching lines...) Expand all
61 current_run_loop = nullptr; 61 current_run_loop = nullptr;
62 return true; 62 return true;
63 } 63 }
64 64
65 void WindowServerTestBase::SetUp() { 65 void WindowServerTestBase::SetUp() {
66 WindowServerShellTestBase::SetUp(); 66 WindowServerShellTestBase::SetUp();
67 67
68 CreateWindowTreeHost(connector(), this, &host_, this); 68 CreateWindowTreeHost(connector(), this, &host_, this);
69 69
70 ASSERT_TRUE(DoRunLoopWithTimeout()); // RunLoop should be quit by OnEmbed(). 70 ASSERT_TRUE(DoRunLoopWithTimeout()); // RunLoop should be quit by OnEmbed().
71 std::swap(window_manager_, most_recent_connection_); 71 std::swap(window_manager_, most_recent_client_);
72 } 72 }
73 73
74 bool WindowServerTestBase::AcceptConnection(shell::Connection* connection) { 74 bool WindowServerTestBase::AcceptConnection(shell::Connection* connection) {
75 connection->AddInterface<mojom::WindowTreeClient>(this); 75 connection->AddInterface<mojom::WindowTreeClient>(this);
76 return true; 76 return true;
77 } 77 }
78 78
79 void WindowServerTestBase::OnEmbed(Window* root) { 79 void WindowServerTestBase::OnEmbed(Window* root) {
80 most_recent_connection_ = root->connection(); 80 most_recent_client_ = root->window_tree();
81 EXPECT_TRUE(QuitRunLoop()); 81 EXPECT_TRUE(QuitRunLoop());
82 ASSERT_TRUE(window_manager_client_); 82 ASSERT_TRUE(window_manager_client_);
83 window_manager_client_->AddActivationParent(root); 83 window_manager_client_->AddActivationParent(root);
84 } 84 }
85 85
86 void WindowServerTestBase::OnConnectionLost(WindowTreeConnection* connection) { 86 void WindowServerTestBase::OnWindowTreeClientDestroyed(
87 window_tree_connection_destroyed_ = true; 87 WindowTreeClient* client) {
88 window_tree_client_destroyed_ = true;
88 } 89 }
89 90
90 void WindowServerTestBase::OnEventObserved(const ui::Event& event, 91 void WindowServerTestBase::OnEventObserved(const ui::Event& event,
91 Window* target) {} 92 Window* target) {}
92 93
93 void WindowServerTestBase::SetWindowManagerClient(WindowManagerClient* client) { 94 void WindowServerTestBase::SetWindowManagerClient(WindowManagerClient* client) {
94 window_manager_client_ = client; 95 window_manager_client_ = client;
95 } 96 }
96 97
97 bool WindowServerTestBase::OnWmSetBounds(Window* window, gfx::Rect* bounds) { 98 bool WindowServerTestBase::OnWmSetBounds(Window* window, gfx::Rect* bounds) {
(...skipping 23 matching lines...) Expand all
121 bool janky) { 122 bool janky) {
122 if (window_manager_delegate_) 123 if (window_manager_delegate_)
123 window_manager_delegate_->OnWmClientJankinessChanged(client_windows, janky); 124 window_manager_delegate_->OnWmClientJankinessChanged(client_windows, janky);
124 } 125 }
125 126
126 void WindowServerTestBase::OnAccelerator(uint32_t id, const ui::Event& event) { 127 void WindowServerTestBase::OnAccelerator(uint32_t id, const ui::Event& event) {
127 if (window_manager_delegate_) 128 if (window_manager_delegate_)
128 window_manager_delegate_->OnAccelerator(id, event); 129 window_manager_delegate_->OnAccelerator(id, event);
129 } 130 }
130 131
131 void WindowServerTestBase::Create( 132 void WindowServerTestBase::Create(shell::Connection* connection,
132 shell::Connection* connection, 133 mojom::WindowTreeClientRequest request) {
133 mojo::InterfaceRequest<mojom::WindowTreeClient> request) { 134 new WindowTreeClient(this, nullptr, std::move(request));
134 WindowTreeConnection::Create(
135 this, std::move(request),
136 WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
137 } 135 }
138 136
139 } // namespace mus 137 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698