OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/protocol/fake_session.h" | 5 #include "remoting/protocol/fake_session.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "net/base/address_list.h" | 9 #include "net/base/address_list.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace remoting { | 15 namespace remoting { |
16 namespace protocol { | 16 namespace protocol { |
17 | 17 |
18 const char kTestJid[] = "host1@gmail.com/chromoting123"; | 18 const char kTestJid[] = "host1@gmail.com/chromoting123"; |
19 | 19 |
20 FakeSocket::FakeSocket() | 20 FakeSocket::FakeSocket() |
21 : async_write_(false), | 21 : async_write_(false), |
22 write_pending_(false), | 22 write_pending_(false), |
23 write_limit_(0), | 23 write_limit_(0), |
24 next_write_error_(net::OK), | 24 next_write_error_(net::OK), |
25 next_read_error_(net::OK), | 25 next_read_error_(net::OK), |
26 read_pending_(false), | 26 read_pending_(false), |
27 read_buffer_size_(0), | 27 read_buffer_size_(0), |
28 input_pos_(0), | 28 input_pos_(0), |
29 message_loop_(MessageLoop::current()), | 29 message_loop_(MessageLoop::current()), |
30 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 30 weak_factory_(this) { |
31 } | 31 } |
32 | 32 |
33 FakeSocket::~FakeSocket() { | 33 FakeSocket::~FakeSocket() { |
34 EXPECT_EQ(message_loop_, MessageLoop::current()); | 34 EXPECT_EQ(message_loop_, MessageLoop::current()); |
35 } | 35 } |
36 | 36 |
37 void FakeSocket::AppendInputData(const std::vector<char>& data) { | 37 void FakeSocket::AppendInputData(const std::vector<char>& data) { |
38 EXPECT_EQ(message_loop_, MessageLoop::current()); | 38 EXPECT_EQ(message_loop_, MessageLoop::current()); |
39 input_data_.insert(input_data_.end(), data.begin(), data.end()); | 39 input_data_.insert(input_data_.end(), data.begin(), data.end()); |
40 // Complete pending read if any. | 40 // Complete pending read if any. |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 FakeSession::FakeSession() | 273 FakeSession::FakeSession() |
274 : event_handler_(NULL), | 274 : event_handler_(NULL), |
275 candidate_config_(CandidateSessionConfig::CreateDefault()), | 275 candidate_config_(CandidateSessionConfig::CreateDefault()), |
276 config_(SessionConfig::ForTest()), | 276 config_(SessionConfig::ForTest()), |
277 message_loop_(MessageLoop::current()), | 277 message_loop_(MessageLoop::current()), |
278 async_creation_(false), | 278 async_creation_(false), |
279 jid_(kTestJid), | 279 jid_(kTestJid), |
280 error_(OK), | 280 error_(OK), |
281 closed_(false), | 281 closed_(false), |
282 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 282 weak_factory_(this) { |
283 } | 283 } |
284 | 284 |
285 FakeSession::~FakeSession() { } | 285 FakeSession::~FakeSession() { } |
286 | 286 |
287 FakeSocket* FakeSession::GetStreamChannel(const std::string& name) { | 287 FakeSocket* FakeSession::GetStreamChannel(const std::string& name) { |
288 return stream_channels_[name]; | 288 return stream_channels_[name]; |
289 } | 289 } |
290 | 290 |
291 FakeUdpSocket* FakeSession::GetDatagramChannel(const std::string& name) { | 291 FakeUdpSocket* FakeSession::GetDatagramChannel(const std::string& name) { |
292 return datagram_channels_[name]; | 292 return datagram_channels_[name]; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 callback.Run(scoped_ptr<net::Socket>(datagram_channels_[name])); | 380 callback.Run(scoped_ptr<net::Socket>(datagram_channels_[name])); |
381 } | 381 } |
382 | 382 |
383 void FakeSession::CancelChannelCreation(const std::string& name) { | 383 void FakeSession::CancelChannelCreation(const std::string& name) { |
384 stream_channels_.erase(name); | 384 stream_channels_.erase(name); |
385 datagram_channels_.erase(name); | 385 datagram_channels_.erase(name); |
386 } | 386 } |
387 | 387 |
388 } // namespace protocol | 388 } // namespace protocol |
389 } // namespace remoting | 389 } // namespace remoting |
OLD | NEW |