OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ | 11 #ifndef WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ |
12 #define WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ | 12 #define WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
| 18 #include "webrtc/p2p/base/candidatepairinterface.h" |
18 #include "webrtc/p2p/base/transport.h" | 19 #include "webrtc/p2p/base/transport.h" |
19 #include "webrtc/p2p/base/transportchannel.h" | 20 #include "webrtc/p2p/base/transportchannel.h" |
20 #include "webrtc/p2p/base/transportcontroller.h" | 21 #include "webrtc/p2p/base/transportcontroller.h" |
21 #include "webrtc/p2p/base/transportchannelimpl.h" | 22 #include "webrtc/p2p/base/transportchannelimpl.h" |
22 #include "webrtc/base/bind.h" | 23 #include "webrtc/base/bind.h" |
23 #include "webrtc/base/buffer.h" | 24 #include "webrtc/base/buffer.h" |
24 #include "webrtc/base/fakesslidentity.h" | 25 #include "webrtc/base/fakesslidentity.h" |
25 #include "webrtc/base/messagequeue.h" | 26 #include "webrtc/base/messagequeue.h" |
26 #include "webrtc/base/sigslot.h" | 27 #include "webrtc/base/sigslot.h" |
27 #include "webrtc/base/sslfingerprint.h" | 28 #include "webrtc/base/sslfingerprint.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 // This map just tracks the FakeTransportChannels created by this class. | 446 // This map just tracks the FakeTransportChannels created by this class. |
446 // It's mainly needed so that we can access a FakeTransportChannel directly, | 447 // It's mainly needed so that we can access a FakeTransportChannel directly, |
447 // even if wrapped by a DtlsTransportChannelWrapper. | 448 // even if wrapped by a DtlsTransportChannelWrapper. |
448 ChannelMap channels_; | 449 ChannelMap channels_; |
449 FakeTransport* dest_ = nullptr; | 450 FakeTransport* dest_ = nullptr; |
450 bool async_ = false; | 451 bool async_ = false; |
451 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; | 452 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; |
452 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; | 453 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; |
453 }; | 454 }; |
454 | 455 |
| 456 // Fake candidate pair class, which can be passed to BaseChannel for testing |
| 457 // purposes. |
| 458 class FakeCandidatePair : public CandidatePairInterface { |
| 459 public: |
| 460 FakeCandidatePair(const Candidate& local_candidate, |
| 461 const Candidate& remote_candidate) |
| 462 : local_candidate_(local_candidate), |
| 463 remote_candidate_(remote_candidate) {} |
| 464 const Candidate& local_candidate() const override { return local_candidate_; } |
| 465 const Candidate& remote_candidate() const override { |
| 466 return remote_candidate_; |
| 467 } |
| 468 |
| 469 private: |
| 470 Candidate local_candidate_; |
| 471 Candidate remote_candidate_; |
| 472 }; |
| 473 |
455 // Fake TransportController class, which can be passed into a BaseChannel object | 474 // Fake TransportController class, which can be passed into a BaseChannel object |
456 // for test purposes. Can be connected to other FakeTransportControllers via | 475 // for test purposes. Can be connected to other FakeTransportControllers via |
457 // Connect(). | 476 // Connect(). |
458 // | 477 // |
459 // This fake is unusual in that for the most part, it's implemented with the | 478 // This fake is unusual in that for the most part, it's implemented with the |
460 // real TransportController code, but with fake TransportChannels underneath. | 479 // real TransportController code, but with fake TransportChannels underneath. |
461 class FakeTransportController : public TransportController { | 480 class FakeTransportController : public TransportController { |
462 public: | 481 public: |
463 FakeTransportController() | 482 FakeTransportController() |
464 : TransportController(rtc::Thread::Current(), | 483 : TransportController(rtc::Thread::Current(), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 515 |
497 TransportChannel* CreateTransportChannel_w(const std::string& transport_name, | 516 TransportChannel* CreateTransportChannel_w(const std::string& transport_name, |
498 int component) override { | 517 int component) override { |
499 if (fail_create_channel_) { | 518 if (fail_create_channel_) { |
500 return nullptr; | 519 return nullptr; |
501 } | 520 } |
502 return TransportController::CreateTransportChannel_w(transport_name, | 521 return TransportController::CreateTransportChannel_w(transport_name, |
503 component); | 522 component); |
504 } | 523 } |
505 | 524 |
| 525 FakeCandidatePair* CreateFakeCandidatePair( |
| 526 const rtc::SocketAddress& local_address, |
| 527 int16_t local_network_id, |
| 528 const rtc::SocketAddress& remote_address, |
| 529 int16_t remote_network_id) { |
| 530 Candidate local_candidate(0, "udp", local_address, 0u, "", "", "local", 0, |
| 531 "foundation", local_network_id, 0); |
| 532 Candidate remote_candidate(0, "udp", remote_address, 0u, "", "", "local", 0, |
| 533 "foundation", remote_network_id, 0); |
| 534 return new FakeCandidatePair(local_candidate, remote_candidate); |
| 535 } |
| 536 |
506 void set_fail_channel_creation(bool fail_channel_creation) { | 537 void set_fail_channel_creation(bool fail_channel_creation) { |
507 fail_create_channel_ = fail_channel_creation; | 538 fail_create_channel_ = fail_channel_creation; |
508 } | 539 } |
509 | 540 |
510 protected: | 541 protected: |
511 Transport* CreateTransport_w(const std::string& transport_name) override { | 542 Transport* CreateTransport_w(const std::string& transport_name) override { |
512 return new FakeTransport(transport_name); | 543 return new FakeTransport(transport_name); |
513 } | 544 } |
514 | 545 |
515 void Connect_w(FakeTransportController* dest) { | 546 void Connect_w(FakeTransportController* dest) { |
(...skipping 14 matching lines...) Expand all Loading... |
530 } | 561 } |
531 } | 562 } |
532 | 563 |
533 private: | 564 private: |
534 bool fail_create_channel_; | 565 bool fail_create_channel_; |
535 }; | 566 }; |
536 | 567 |
537 } // namespace cricket | 568 } // namespace cricket |
538 | 569 |
539 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ | 570 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ |
OLD | NEW |