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

Side by Side Diff: remoting/host/it2me/it2me_host_unittest.cc

Issue 2925733003: Report signling errors for register-support-host requests. (Closed)
Patch Set: Fix memory leak Created 3 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
« no previous file with comments | « no previous file | remoting/host/register_support_host_request.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "remoting/host/it2me/it2me_host.h" 5 #include "remoting/host/it2me/it2me_host.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 std::unique_ptr<base::DictionaryValue> policies_; 176 std::unique_ptr<base::DictionaryValue> policies_;
177 177
178 scoped_refptr<It2MeHost> it2me_host_; 178 scoped_refptr<It2MeHost> it2me_host_;
179 179
180 private: 180 private:
181 void StartupHostStateHelper(const base::Closure& quit_closure); 181 void StartupHostStateHelper(const base::Closure& quit_closure);
182 182
183 std::unique_ptr<base::MessageLoop> message_loop_; 183 std::unique_ptr<base::MessageLoop> message_loop_;
184 std::unique_ptr<base::RunLoop> run_loop_; 184 std::unique_ptr<base::RunLoop> run_loop_;
185 std::unique_ptr<FakeSignalStrategy> fake_bot_signal_strategy_;
185 186
186 std::unique_ptr<ChromotingHostContext> host_context_; 187 std::unique_ptr<ChromotingHostContext> host_context_;
187 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; 188 scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
188 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; 189 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
189 190
190 base::WeakPtrFactory<It2MeHostTest> weak_factory_; 191 base::WeakPtrFactory<It2MeHostTest> weak_factory_;
191 192
192 DISALLOW_COPY_AND_ASSIGN(It2MeHostTest); 193 DISALLOW_COPY_AND_ASSIGN(It2MeHostTest);
193 }; 194 };
194 195
195 It2MeHostTest::It2MeHostTest() : weak_factory_(this) {} 196 It2MeHostTest::It2MeHostTest() : weak_factory_(this) {}
196 It2MeHostTest::~It2MeHostTest() {} 197 It2MeHostTest::~It2MeHostTest() {}
197 198
198 void It2MeHostTest::SetUp() { 199 void It2MeHostTest::SetUp() {
199 #if defined(OS_LINUX) 200 #if defined(OS_LINUX)
200 // Need to prime the host OS version value for linux to prevent IO on the 201 // Need to prime the host OS version value for linux to prevent IO on the
201 // network thread. base::GetLinuxDistro() caches the result. 202 // network thread. base::GetLinuxDistro() caches the result.
202 base::GetLinuxDistro(); 203 base::GetLinuxDistro();
203 #endif 204 #endif
204 message_loop_.reset(new base::MessageLoop()); 205 message_loop_.reset(new base::MessageLoop());
205 run_loop_.reset(new base::RunLoop()); 206 run_loop_.reset(new base::RunLoop());
206 207
207 host_context_ = ChromotingHostContext::Create(new AutoThreadTaskRunner( 208 host_context_ = ChromotingHostContext::Create(new AutoThreadTaskRunner(
208 base::ThreadTaskRunnerHandle::Get(), run_loop_->QuitClosure())); 209 base::ThreadTaskRunnerHandle::Get(), run_loop_->QuitClosure()));
209 network_task_runner_ = host_context_->network_task_runner(); 210 network_task_runner_ = host_context_->network_task_runner();
210 ui_task_runner_ = host_context_->ui_task_runner(); 211 ui_task_runner_ = host_context_->ui_task_runner();
212 fake_bot_signal_strategy_.reset(
213 new FakeSignalStrategy(SignalingAddress("fake_bot_jid")));
211 } 214 }
212 215
213 void It2MeHostTest::TearDown() { 216 void It2MeHostTest::TearDown() {
214 // Shutdown the host if it hasn't been already. Without this, the call to 217 // Shutdown the host if it hasn't been already. Without this, the call to
215 // run_loop_->Run() may never return. 218 // run_loop_->Run() may never return.
216 it2me_host_->Disconnect(); 219 it2me_host_->Disconnect();
217 network_task_runner_ = nullptr; 220 network_task_runner_ = nullptr;
218 ui_task_runner_ = nullptr; 221 ui_task_runner_ = nullptr;
219 host_context_.reset(); 222 host_context_.reset();
220 it2me_host_ = nullptr; 223 it2me_host_ = nullptr;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 264
262 std::unique_ptr<FakeIt2MeDialogFactory> dialog_factory( 265 std::unique_ptr<FakeIt2MeDialogFactory> dialog_factory(
263 new FakeIt2MeDialogFactory()); 266 new FakeIt2MeDialogFactory());
264 dialog_factory_ = dialog_factory.get(); 267 dialog_factory_ = dialog_factory.get();
265 268
266 protocol::IceConfig ice_config; 269 protocol::IceConfig ice_config;
267 ice_config.stun_servers.push_back(rtc::SocketAddress(kTestStunServer, 100)); 270 ice_config.stun_servers.push_back(rtc::SocketAddress(kTestStunServer, 100));
268 ice_config.expiration_time = 271 ice_config.expiration_time =
269 base::Time::Now() + base::TimeDelta::FromHours(1); 272 base::Time::Now() + base::TimeDelta::FromHours(1);
270 273
274 auto fake_signal_strategy =
275 base::MakeUnique<FakeSignalStrategy>(SignalingAddress("fake_local_jid"));
276 fake_bot_signal_strategy_->ConnectTo(fake_signal_strategy.get());
277
271 it2me_host_ = new It2MeHost(); 278 it2me_host_ = new It2MeHost();
272 it2me_host_->Connect(host_context_->Copy(), 279 it2me_host_->Connect(host_context_->Copy(),
273 base::MakeUnique<base::DictionaryValue>(*policies_), 280 base::MakeUnique<base::DictionaryValue>(*policies_),
274 std::move(dialog_factory), weak_factory_.GetWeakPtr(), 281 std::move(dialog_factory), weak_factory_.GetWeakPtr(),
275 base::WrapUnique(new FakeSignalStrategy( 282 std::move(fake_signal_strategy), kTestUserName,
276 SignalingAddress("fake_local_jid"))), 283 "fake_bot_jid", ice_config);
277 kTestUserName, "fake_bot_jid", ice_config);
278 284
279 base::RunLoop run_loop; 285 base::RunLoop run_loop;
280 state_change_callback_ = 286 state_change_callback_ =
281 base::Bind(&It2MeHostTest::StartupHostStateHelper, base::Unretained(this), 287 base::Bind(&It2MeHostTest::StartupHostStateHelper, base::Unretained(this),
282 run_loop.QuitClosure()); 288 run_loop.QuitClosure());
283 run_loop.Run(); 289 run_loop.Run();
284 } 290 }
285 291
286 void It2MeHostTest::RunUntilStateChanged(It2MeHostState expected_state) { 292 void It2MeHostTest::RunUntilStateChanged(It2MeHostState expected_state) {
287 if (last_host_state_ == expected_state) { 293 if (last_host_state_ == expected_state) {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 ASSERT_EQ(ValidationResult::SUCCESS, validation_result_); 597 ASSERT_EQ(ValidationResult::SUCCESS, validation_result_);
592 ASSERT_EQ(It2MeHostState::kConnecting, last_host_state_); 598 ASSERT_EQ(It2MeHostState::kConnecting, last_host_state_);
593 599
594 RunValidationCallback(kTestClientJid2); 600 RunValidationCallback(kTestClientJid2);
595 ASSERT_EQ(ValidationResult::ERROR_TOO_MANY_CONNECTIONS, validation_result_); 601 ASSERT_EQ(ValidationResult::ERROR_TOO_MANY_CONNECTIONS, validation_result_);
596 RunUntilStateChanged(It2MeHostState::kDisconnected); 602 RunUntilStateChanged(It2MeHostState::kDisconnected);
597 ASSERT_EQ(It2MeHostState::kDisconnected, last_host_state_); 603 ASSERT_EQ(It2MeHostState::kDisconnected, last_host_state_);
598 } 604 }
599 605
600 } // namespace remoting 606 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/register_support_host_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698