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

Side by Side Diff: webrtc/p2p/base/mockicetransport.h

Issue 2606123002: Remove the dependency of TransportChannel and TransportChannelImpl. (Closed)
Patch Set: Merge Created 3 years, 11 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 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 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_MOCKICETRANSPORT_H_ 11 #ifndef WEBRTC_P2P_BASE_MOCKICETRANSPORT_H_
12 #define WEBRTC_P2P_BASE_MOCKICETRANSPORT_H_ 12 #define WEBRTC_P2P_BASE_MOCKICETRANSPORT_H_
13 13
14 #include <memory> 14 #include <memory>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/base/gunit.h" 18 #include "webrtc/base/gunit.h"
19 #include "webrtc/p2p/base/icetransportinternal.h" 19 #include "webrtc/p2p/base/icetransportinternal.h"
20 #include "webrtc/test/gmock.h" 20 #include "webrtc/test/gmock.h"
21 21
22 using testing::_; 22 using testing::_;
23 using testing::Return; 23 using testing::Return;
24 24
25 namespace cricket { 25 namespace cricket {
26 26
27 // Used in Chromium/remoting/protocol/channel_socket_adapter_unittest.cc 27 // Used in Chromium/remoting/protocol/channel_socket_adapter_unittest.cc
28 class MockIceTransport : public cricket::TransportChannel { 28 class MockIceTransport : public IceTransportInternal {
29 public: 29 public:
30 MockIceTransport() : cricket::TransportChannel(std::string(), 0) { 30 MockIceTransport() {
31 set_writable(true); 31 SignalReadyToSend(this);
32 SignalWritableState(this);
32 } 33 }
33 34
34 MOCK_METHOD4(SendPacket, 35 MOCK_METHOD4(SendPacket,
35 int(const char* data, 36 int(const char* data,
36 size_t len, 37 size_t len,
37 const rtc::PacketOptions& options, 38 const rtc::PacketOptions& options,
38 int flags)); 39 int flags));
39 MOCK_METHOD2(SetOption, int(rtc::Socket::Option opt, int value)); 40 MOCK_METHOD2(SetOption, int(rtc::Socket::Option opt, int value));
40 MOCK_METHOD0(GetError, int()); 41 MOCK_METHOD0(GetError, int());
41 MOCK_CONST_METHOD0(GetIceRole, cricket::IceRole()); 42 MOCK_CONST_METHOD0(GetIceRole, cricket::IceRole());
42 MOCK_METHOD1(GetStats, bool(cricket::ConnectionInfos* infos)); 43 MOCK_METHOD1(GetStats, bool(cricket::ConnectionInfos* infos));
43 MOCK_CONST_METHOD0(IsDtlsActive, bool()); 44 MOCK_CONST_METHOD0(IsDtlsActive, bool());
44 MOCK_CONST_METHOD1(GetSslRole, bool(rtc::SSLRole* role)); 45 MOCK_CONST_METHOD1(GetSslRole, bool(rtc::SSLRole* role));
45 MOCK_METHOD1(SetSrtpCiphers, bool(const std::vector<std::string>& ciphers));
46 MOCK_METHOD1(GetSrtpCipher, bool(std::string* cipher));
47 MOCK_METHOD1(GetSslCipher, bool(std::string* cipher));
48 MOCK_CONST_METHOD0(GetLocalCertificate,
49 rtc::scoped_refptr<rtc::RTCCertificate>());
50 46
51 // This can't be a real mock method because gmock doesn't support move-only 47 IceTransportState GetState() const override {
52 // return values. 48 return IceTransportState::STATE_INIT;
53 std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate() 49 }
54 const override { 50 const std::string& transport_name() const override { return transport_name_; }
55 EXPECT_TRUE(false); // Never called. 51 int component() const override { return 0; }
56 return nullptr; 52 void SetIceRole(IceRole role) override {}
53 void SetIceTiebreaker(uint64_t tiebreaker) override {}
54 // The ufrag and pwd in |ice_params| must be set
55 // before candidate gathering can start.
56 void SetIceParameters(const IceParameters& ice_params) override {}
57 void SetRemoteIceParameters(const IceParameters& ice_params) override {}
58 void SetRemoteIceMode(IceMode mode) override {}
59 void SetIceConfig(const IceConfig& config) override {}
60 void MaybeStartGathering() override {}
61 void SetMetricsObserver(webrtc::MetricsObserverInterface* observer) override {
62 }
63 void AddRemoteCandidate(const Candidate& candidate) override {}
64 void RemoveRemoteCandidate(const Candidate& candidate) override {}
65 IceGatheringState gathering_state() const override {
66 return IceGatheringState::kIceGatheringComplete;
57 } 67 }
58 68
59 MOCK_METHOD6(ExportKeyingMaterial, 69 bool receiving() const override { return true; }
60 bool(const std::string& label, 70 bool writable() const override { return true; }
61 const uint8_t* context, 71
62 size_t context_len, 72 private:
63 bool use_context, 73 std::string transport_name_;
Taylor Brandstetter 2017/01/10 19:43:47 Looks like this is never set? Can transport_name()
Zhi Huang 2017/01/12 20:04:12 A local variable won't work here because the trans
Taylor Brandstetter 2017/01/13 01:45:58 Acknowledged.
64 uint8_t* result,
65 size_t result_len));
66 }; 74 };
67 75
68 } // namespace cricket 76 } // namespace cricket
69 77
70 #endif // WEBRTC_P2P_BASE_MOCKICETRANSPORT_H_ 78 #endif // WEBRTC_P2P_BASE_MOCKICETRANSPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698