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

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

Issue 2925733003: Report signling errors for register-support-host requests. (Closed)
Patch Set: 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
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // Used to set ConfirmationDialog behavior. 169 // Used to set ConfirmationDialog behavior.
170 FakeIt2MeDialogFactory* dialog_factory_ = nullptr; 170 FakeIt2MeDialogFactory* dialog_factory_ = nullptr;
171 171
172 scoped_refptr<It2MeHost> it2me_host_; 172 scoped_refptr<It2MeHost> it2me_host_;
173 173
174 private: 174 private:
175 void StartupHostStateHelper(const base::Closure& quit_closure); 175 void StartupHostStateHelper(const base::Closure& quit_closure);
176 176
177 std::unique_ptr<base::MessageLoop> message_loop_; 177 std::unique_ptr<base::MessageLoop> message_loop_;
178 std::unique_ptr<base::RunLoop> run_loop_; 178 std::unique_ptr<base::RunLoop> run_loop_;
179 std::unique_ptr<FakeSignalStrategy> fake_client_signal_strategy_;
179 180
180 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; 181 scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
181 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; 182 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
182 183
183 base::WeakPtrFactory<It2MeHostTest> weak_factory_; 184 base::WeakPtrFactory<It2MeHostTest> weak_factory_;
184 185
185 DISALLOW_COPY_AND_ASSIGN(It2MeHostTest); 186 DISALLOW_COPY_AND_ASSIGN(It2MeHostTest);
186 }; 187 };
187 188
188 It2MeHostTest::It2MeHostTest() : weak_factory_(this) {} 189 It2MeHostTest::It2MeHostTest() : weak_factory_(this) {}
(...skipping 11 matching lines...) Expand all
200 201
201 std::unique_ptr<ChromotingHostContext> host_context( 202 std::unique_ptr<ChromotingHostContext> host_context(
202 ChromotingHostContext::Create(new AutoThreadTaskRunner( 203 ChromotingHostContext::Create(new AutoThreadTaskRunner(
203 base::ThreadTaskRunnerHandle::Get(), run_loop_->QuitClosure()))); 204 base::ThreadTaskRunnerHandle::Get(), run_loop_->QuitClosure())));
204 network_task_runner_ = host_context->network_task_runner(); 205 network_task_runner_ = host_context->network_task_runner();
205 ui_task_runner_ = host_context->ui_task_runner(); 206 ui_task_runner_ = host_context->ui_task_runner();
206 207
207 std::unique_ptr<FakeIt2MeDialogFactory> dialog_factory( 208 std::unique_ptr<FakeIt2MeDialogFactory> dialog_factory(
208 new FakeIt2MeDialogFactory()); 209 new FakeIt2MeDialogFactory());
209 dialog_factory_ = dialog_factory.get(); 210 dialog_factory_ = dialog_factory.get();
210 it2me_host_ = new It2MeHost( 211 fake_client_signal_strategy_.reset(
211 std::move(host_context), 212 new FakeSignalStrategy(SignalingAddress("fake_client_jid")));
212 std::move(dialog_factory), weak_factory_.GetWeakPtr(), 213 auto fake_signal_strategy =
213 base::WrapUnique( 214 base::MakeUnique<FakeSignalStrategy>(SignalingAddress("fake_local_jid"));
214 new FakeSignalStrategy(SignalingAddress("fake_local_jid"))), 215 fake_client_signal_strategy_->ConnectTo(fake_signal_strategy.get());
kelvinp 2017/06/06 01:03:54 Since now we report signaling errors properly, we
215 kTestUserName, "fake_bot_jid"); 216
217 it2me_host_ =
218 new It2MeHost(std::move(host_context), std::move(dialog_factory),
219 weak_factory_.GetWeakPtr(), std::move(fake_signal_strategy),
220 kTestUserName, "fake_bot_jid");
216 221
217 it2me_host_->OnPolicyUpdate(PolicyWatcher::GetDefaultPolicies()); 222 it2me_host_->OnPolicyUpdate(PolicyWatcher::GetDefaultPolicies());
218 } 223 }
219 224
220 void It2MeHostTest::TearDown() { 225 void It2MeHostTest::TearDown() {
221 // Shutdown the host if it hasn't been already. Without this, the call to 226 // Shutdown the host if it hasn't been already. Without this, the call to
222 // run_loop_->Run() may never return. 227 // run_loop_->Run() may never return.
223 it2me_host_->Disconnect(); 228 it2me_host_->Disconnect();
224 network_task_runner_ = nullptr; 229 network_task_runner_ = nullptr;
225 ui_task_runner_ = nullptr; 230 ui_task_runner_ = nullptr;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 ASSERT_EQ(ValidationResult::SUCCESS, validation_result_); 560 ASSERT_EQ(ValidationResult::SUCCESS, validation_result_);
556 ASSERT_EQ(It2MeHostState::kConnecting, last_host_state_); 561 ASSERT_EQ(It2MeHostState::kConnecting, last_host_state_);
557 562
558 RunValidationCallback(kTestClientJid2); 563 RunValidationCallback(kTestClientJid2);
559 ASSERT_EQ(ValidationResult::ERROR_TOO_MANY_CONNECTIONS, validation_result_); 564 ASSERT_EQ(ValidationResult::ERROR_TOO_MANY_CONNECTIONS, validation_result_);
560 RunUntilStateChanged(It2MeHostState::kDisconnected); 565 RunUntilStateChanged(It2MeHostState::kDisconnected);
561 ASSERT_EQ(It2MeHostState::kDisconnected, last_host_state_); 566 ASSERT_EQ(It2MeHostState::kDisconnected, last_host_state_);
562 } 567 }
563 568
564 } // namespace remoting 569 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/register_support_host_request.cc » ('j') | remoting/host/register_support_host_request.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698