Move AudioDecoder and AudioDecoderFactory mocks to webrtc/test/

AudioDecoder and AudioDecoderFactory are in webrtc/api/ now, so move
their mocks to someplace central where tests from all over WebRTC are
allowed to #include them.

BUG=webrtc:5805

Review-Url: https://codereview.webrtc.org/2798063004
Cr-Commit-Position: refs/heads/master@{#17619}
This commit is contained in:
kwiberg
2017-04-10 05:15:48 -07:00
committed by Commit bot
parent 2fa97fdbe5
commit 37e99fd3fa
16 changed files with 34 additions and 24 deletions

View File

@ -2064,7 +2064,6 @@ if (rtc_include_tests) {
"neteq/dtmf_tone_generator_unittest.cc",
"neteq/expand_unittest.cc",
"neteq/merge_unittest.cc",
"neteq/mock/mock_audio_decoder.h",
"neteq/mock/mock_buffer_level_filter.h",
"neteq/mock/mock_decoder_database.h",
"neteq/mock/mock_delay_manager.h",
@ -2126,6 +2125,7 @@ if (rtc_include_tests) {
"../../base:rtc_base_tests_utils",
"../../common_audio",
"../../system_wrappers:system_wrappers",
"../../test:audio_codec_mocks",
"../../test:field_trial",
"../../test:rtp_test_utils",
"../../test:test_common",

View File

@ -30,7 +30,6 @@
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
#include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h"
#include "webrtc/modules/audio_coding/neteq/tools/audio_checksum.h"
#include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h"
#include "webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h"
@ -44,6 +43,7 @@
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/sleep.h"
#include "webrtc/test/gtest.h"
#include "webrtc/test/mock_audio_decoder.h"
#include "webrtc/test/testsupport/fileutils.h"
using ::testing::AtLeast;

View File

@ -1,83 +0,0 @@
/*
* Copyright (c) 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_MODULES_AUDIO_CODING_CODECS_MOCK_MOCK_AUDIO_DECODER_FACTORY_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_MOCK_MOCK_AUDIO_DECODER_FACTORY_H_
#include <vector>
#include "webrtc/api/audio_codecs/audio_decoder_factory.h"
#include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h"
#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/test/gmock.h"
namespace webrtc {
class MockAudioDecoderFactory : public AudioDecoderFactory {
public:
MOCK_METHOD0(GetSupportedDecoders, std::vector<AudioCodecSpec>());
MOCK_METHOD1(IsSupportedDecoder, bool(const SdpAudioFormat&));
std::unique_ptr<AudioDecoder> MakeAudioDecoder(
const SdpAudioFormat& format) {
std::unique_ptr<AudioDecoder> return_value;
MakeAudioDecoderMock(format, &return_value);
return return_value;
}
MOCK_METHOD2(MakeAudioDecoderMock,
void(const SdpAudioFormat& format,
std::unique_ptr<AudioDecoder>* return_value));
// Creates a MockAudioDecoderFactory with no formats and that may not be
// invoked to create a codec - useful for initializing a voice engine, for
// example.
static rtc::scoped_refptr<webrtc::MockAudioDecoderFactory>
CreateUnusedFactory() {
using testing::_;
using testing::AnyNumber;
using testing::Return;
rtc::scoped_refptr<webrtc::MockAudioDecoderFactory> factory =
new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>;
ON_CALL(*factory.get(), GetSupportedDecoders())
.WillByDefault(Return(std::vector<webrtc::AudioCodecSpec>()));
EXPECT_CALL(*factory.get(), GetSupportedDecoders()).Times(AnyNumber());
ON_CALL(*factory, IsSupportedDecoder(_)).WillByDefault(Return(false));
EXPECT_CALL(*factory, IsSupportedDecoder(_)).Times(AnyNumber());
EXPECT_CALL(*factory.get(), MakeAudioDecoderMock(_, _)).Times(0);
return factory;
}
// Creates a MockAudioDecoderFactory with no formats that may be invoked to
// create a codec any number of times. It will, though, return nullptr on each
// call, since it supports no codecs.
static rtc::scoped_refptr<webrtc::MockAudioDecoderFactory>
CreateEmptyFactory() {
using testing::_;
using testing::AnyNumber;
using testing::Return;
using testing::SetArgPointee;
rtc::scoped_refptr<webrtc::MockAudioDecoderFactory> factory =
new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>;
ON_CALL(*factory.get(), GetSupportedDecoders())
.WillByDefault(Return(std::vector<webrtc::AudioCodecSpec>()));
EXPECT_CALL(*factory.get(), GetSupportedDecoders()).Times(AnyNumber());
ON_CALL(*factory, IsSupportedDecoder(_)).WillByDefault(Return(false));
EXPECT_CALL(*factory, IsSupportedDecoder(_)).Times(AnyNumber());
ON_CALL(*factory.get(), MakeAudioDecoderMock(_, _))
.WillByDefault(SetArgPointee<1>(nullptr));
EXPECT_CALL(*factory.get(), MakeAudioDecoderMock(_, _)).Times(AnyNumber());
return factory;
}
};
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_MOCK_MOCK_AUDIO_DECODER_FACTORY_H_

View File

@ -10,15 +10,15 @@
// Unit tests for DecisionLogic class and derived classes.
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h"
#include "webrtc/modules/audio_coding/neteq/buffer_level_filter.h"
#include "webrtc/modules/audio_coding/neteq/decision_logic.h"
#include "webrtc/modules/audio_coding/neteq/buffer_level_filter.h"
#include "webrtc/modules/audio_coding/neteq/decoder_database.h"
#include "webrtc/modules/audio_coding/neteq/delay_manager.h"
#include "webrtc/modules/audio_coding/neteq/delay_peak_detector.h"
#include "webrtc/modules/audio_coding/neteq/packet_buffer.h"
#include "webrtc/modules/audio_coding/neteq/tick_timer.h"
#include "webrtc/test/gtest.h"
#include "webrtc/test/mock_audio_decoder_factory.h"
namespace webrtc {

View File

@ -16,10 +16,10 @@
#include <string>
#include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h"
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h"
#include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h"
#include "webrtc/test/gmock.h"
#include "webrtc/test/gtest.h"
#include "webrtc/test/mock_audio_decoder.h"
#include "webrtc/test/mock_audio_decoder_factory.h"
using testing::_;
using testing::Invoke;

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 2012 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_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_AUDIO_DECODER_H_
#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_AUDIO_DECODER_H_
#include "webrtc/api/audio_codecs/audio_decoder.h"
#include "webrtc/test/gmock.h"
namespace webrtc {
class MockAudioDecoder : public AudioDecoder {
public:
MockAudioDecoder() {}
virtual ~MockAudioDecoder() { Die(); }
MOCK_METHOD0(Die, void());
MOCK_METHOD5(DecodeInternal,
int(const uint8_t*, size_t, int, int16_t*, SpeechType*));
MOCK_CONST_METHOD0(HasDecodePlc, bool());
MOCK_METHOD2(DecodePlc, size_t(size_t, int16_t*));
MOCK_METHOD0(Reset, void());
MOCK_METHOD5(IncomingPacket, int(const uint8_t*, size_t, uint16_t, uint32_t,
uint32_t));
MOCK_METHOD0(ErrorCode, int());
MOCK_CONST_METHOD2(PacketDuration, int(const uint8_t*, size_t));
MOCK_CONST_METHOD0(Channels, size_t());
MOCK_CONST_METHOD0(SampleRateHz, int());
};
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_AUDIO_DECODER_H_

View File

@ -12,11 +12,9 @@
#include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h"
#include "webrtc/base/safe_conversions.h"
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h"
#include "webrtc/modules/audio_coding/neteq/accelerate.h"
#include "webrtc/modules/audio_coding/neteq/expand.h"
#include "webrtc/modules/audio_coding/neteq/include/neteq.h"
#include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h"
#include "webrtc/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h"
#include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h"
#include "webrtc/modules/audio_coding/neteq/mock/mock_delay_manager.h"
@ -32,6 +30,8 @@
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/test/gmock.h"
#include "webrtc/test/gtest.h"
#include "webrtc/test/mock_audio_decoder.h"
#include "webrtc/test/mock_audio_decoder_factory.h"
using ::testing::AtLeast;
using ::testing::Return;

View File

@ -18,10 +18,10 @@
#include <utility> // pair
#include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h"
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h"
#include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h"
#include "webrtc/modules/audio_coding/neteq/packet.h"
#include "webrtc/test/gtest.h"
#include "webrtc/test/mock_audio_decoder_factory.h"
using ::testing::Return;
using ::testing::ReturnNull;