Create the MockIceTransport

The src/remoting/protocol/channel_socket_adapter_unittest.cc will use this class
instead of creating its own MockTransportChannel which subclasses the TransportChannel.
This will make it easier to switch the base class of P2PTransportChannel from
TransportChannel to IceTransportInternal.

BUG=webrtc:6951

Review-Url: https://codereview.webrtc.org/2610663003
Cr-Commit-Position: refs/heads/master@{#15922}
This commit is contained in:
zhihuang 2017-01-05 12:21:52 -08:00 committed by Commit bot
parent 92190cb052
commit 1a619cdb5d
2 changed files with 71 additions and 0 deletions

View File

@ -150,6 +150,7 @@ if (rtc_include_tests) {
"base/fakeportallocator.h",
"base/faketransportcontroller.h",
"base/jseptransport_unittest.cc",
"base/mockicetransport.h",
"base/p2ptransportchannel_unittest.cc",
"base/port_unittest.cc",
"base/portallocator_unittest.cc",

View File

@ -0,0 +1,70 @@
/*
* Copyright 2016 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_P2P_BASE_MOCKICETRANSPORT_H_
#define WEBRTC_P2P_BASE_MOCKICETRANSPORT_H_
#include <memory>
#include <string>
#include <vector>
#include "webrtc/base/gunit.h"
#include "webrtc/p2p/base/icetransportinternal.h"
#include "webrtc/test/gmock.h"
using testing::_;
using testing::Return;
namespace cricket {
// Used in Chromium/remoting/protocol/channel_socket_adapter_unittest.cc
class MockIceTransport : public cricket::TransportChannel {
public:
MockIceTransport() : cricket::TransportChannel(std::string(), 0) {
set_writable(true);
}
MOCK_METHOD4(SendPacket,
int(const char* data,
size_t len,
const rtc::PacketOptions& options,
int flags));
MOCK_METHOD2(SetOption, int(rtc::Socket::Option opt, int value));
MOCK_METHOD0(GetError, int());
MOCK_CONST_METHOD0(GetIceRole, cricket::IceRole());
MOCK_METHOD1(GetStats, bool(cricket::ConnectionInfos* infos));
MOCK_CONST_METHOD0(IsDtlsActive, bool());
MOCK_CONST_METHOD1(GetSslRole, bool(rtc::SSLRole* role));
MOCK_METHOD1(SetSrtpCiphers, bool(const std::vector<std::string>& ciphers));
MOCK_METHOD1(GetSrtpCipher, bool(std::string* cipher));
MOCK_METHOD1(GetSslCipher, bool(std::string* cipher));
MOCK_CONST_METHOD0(GetLocalCertificate,
rtc::scoped_refptr<rtc::RTCCertificate>());
// This can't be a real mock method because gmock doesn't support move-only
// return values.
std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate()
const override {
EXPECT_TRUE(false); // Never called.
return nullptr;
}
MOCK_METHOD6(ExportKeyingMaterial,
bool(const std::string& label,
const uint8_t* context,
size_t context_len,
bool use_context,
uint8_t* result,
size_t result_len));
};
} // namespace cricket
#endif // WEBRTC_P2P_BASE_MOCKICETRANSPORT_H_