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

Unified Diff: webrtc/modules/audio_device/android/audio_device_unittest.cc

Issue 2493483002: Created a mock AudioTransport. (Closed)
Patch Set: put cflags where it belongs Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_device/BUILD.gn ('k') | webrtc/modules/audio_device/include/mock_audio_transport.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_device/android/audio_device_unittest.cc
diff --git a/webrtc/modules/audio_device/android/audio_device_unittest.cc b/webrtc/modules/audio_device/android/audio_device_unittest.cc
index eefab0f4e1ca557db04785dc4540538d51f08207..c31e14e1c6fd0c8dc3657407c80071e3896f1b70 100644
--- a/webrtc/modules/audio_device/android/audio_device_unittest.cc
+++ b/webrtc/modules/audio_device/android/audio_device_unittest.cc
@@ -26,6 +26,7 @@
#include "webrtc/modules/audio_device/android/ensure_initialized.h"
#include "webrtc/modules/audio_device/audio_device_impl.h"
#include "webrtc/modules/audio_device/include/audio_device.h"
+#include "webrtc/modules/audio_device/include/mock_audio_transport.h"
#include "webrtc/system_wrappers/include/clock.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/sleep.h"
@@ -367,55 +368,16 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface {
// Mocks the AudioTransport object and proxies actions for the two callbacks
// (RecordedDataIsAvailable and NeedMorePlayData) to different implementations
// of AudioStreamInterface.
-class MockAudioTransport : public AudioTransport {
+class MockAudioTransportAndroid : public test::MockAudioTransport {
public:
- explicit MockAudioTransport(int type)
+ explicit MockAudioTransportAndroid(int type)
: num_callbacks_(0),
type_(type),
play_count_(0),
rec_count_(0),
audio_stream_(nullptr) {}
- virtual ~MockAudioTransport() {}
-
- MOCK_METHOD10(RecordedDataIsAvailable,
- int32_t(const void* audioSamples,
- const size_t nSamples,
- const size_t nBytesPerSample,
- const size_t nChannels,
- const uint32_t samplesPerSec,
- const uint32_t totalDelayMS,
- const int32_t clockDrift,
- const uint32_t currentMicLevel,
- const bool keyPressed,
- uint32_t& newMicLevel));
-
- MOCK_METHOD8(NeedMorePlayData,
- int32_t(const size_t nSamples,
- const size_t nBytesPerSample,
- const size_t nChannels,
- const uint32_t samplesPerSec,
- void* audioSamples,
- size_t& nSamplesOut,
- int64_t* elapsed_time_ms,
- int64_t* ntp_time_ms));
-
- MOCK_METHOD6(PushCaptureData,
- void(int voe_channel,
- const void* audio_data,
- int bits_per_sample,
- int sample_rate,
- size_t number_of_channels,
- size_t number_of_frames));
-
- MOCK_METHOD7(PullRenderData,
- void(int bits_per_sample,
- int sample_rate,
- size_t number_of_channels,
- size_t number_of_frames,
- void* audio_data,
- int64_t* elapsed_time_ms,
- int64_t* ntp_time_ms));
+ virtual ~MockAudioTransportAndroid() {}
// Set default actions of the mock object. We are delegating to fake
// implementations (of AudioStreamInterface) here.
@@ -428,12 +390,12 @@ class MockAudioTransport : public AudioTransport {
if (play_mode()) {
ON_CALL(*this, NeedMorePlayData(_, _, _, _, _, _, _, _))
.WillByDefault(
- Invoke(this, &MockAudioTransport::RealNeedMorePlayData));
+ Invoke(this, &MockAudioTransportAndroid::RealNeedMorePlayData));
}
if (rec_mode()) {
ON_CALL(*this, RecordedDataIsAvailable(_, _, _, _, _, _, _, _, _, _))
- .WillByDefault(
- Invoke(this, &MockAudioTransport::RealRecordedDataIsAvailable));
+ .WillByDefault(Invoke(
+ this, &MockAudioTransportAndroid::RealRecordedDataIsAvailable));
}
}
@@ -899,7 +861,7 @@ TEST_F(AudioDeviceTest, StopRecordingRequiresInitToRestart) {
// Start playout and verify that the native audio layer starts asking for real
// audio samples to play out using the NeedMorePlayData callback.
TEST_F(AudioDeviceTest, StartPlayoutVerifyCallbacks) {
- MockAudioTransport mock(kPlayout);
+ MockAudioTransportAndroid mock(kPlayout);
mock.HandleCallbacks(test_is_done_.get(), nullptr, kNumCallbacks);
EXPECT_CALL(mock, NeedMorePlayData(playout_frames_per_10ms_buffer(),
kBytesPerSample,
@@ -917,7 +879,7 @@ TEST_F(AudioDeviceTest, StartPlayoutVerifyCallbacks) {
// Start recording and verify that the native audio layer starts feeding real
// audio samples via the RecordedDataIsAvailable callback.
TEST_F(AudioDeviceTest, StartRecordingVerifyCallbacks) {
- MockAudioTransport mock(kRecording);
+ MockAudioTransportAndroid mock(kRecording);
mock.HandleCallbacks(test_is_done_.get(), nullptr, kNumCallbacks);
EXPECT_CALL(mock, RecordedDataIsAvailable(NotNull(),
record_frames_per_10ms_buffer(),
@@ -941,7 +903,7 @@ TEST_F(AudioDeviceTest, StartRecordingVerifyCallbacks) {
// Start playout and recording (full-duplex audio) and verify that audio is
// active in both directions.
TEST_F(AudioDeviceTest, StartPlayoutAndRecordingVerifyCallbacks) {
- MockAudioTransport mock(kPlayout | kRecording);
+ MockAudioTransportAndroid mock(kPlayout | kRecording);
mock.HandleCallbacks(test_is_done_.get(), nullptr, kNumCallbacks);
EXPECT_CALL(mock, NeedMorePlayData(playout_frames_per_10ms_buffer(),
kBytesPerSample,
@@ -975,7 +937,7 @@ TEST_F(AudioDeviceTest, StartPlayoutAndRecordingVerifyCallbacks) {
TEST_F(AudioDeviceTest, RunPlayoutWithFileAsSource) {
// TODO(henrika): extend test when mono output is supported.
EXPECT_EQ(1u, playout_channels());
- NiceMock<MockAudioTransport> mock(kPlayout);
+ NiceMock<MockAudioTransportAndroid> mock(kPlayout);
const int num_callbacks = kFilePlayTimeInSec * kNumCallbacksPerSecond;
std::string file_name = GetFileName(playout_sample_rate());
std::unique_ptr<FileAudioStream> file_audio_stream(
@@ -1006,7 +968,7 @@ TEST_F(AudioDeviceTest, RunPlayoutWithFileAsSource) {
TEST_F(AudioDeviceTest, RunPlayoutAndRecordingInFullDuplex) {
EXPECT_EQ(record_channels(), playout_channels());
EXPECT_EQ(record_sample_rate(), playout_sample_rate());
- NiceMock<MockAudioTransport> mock(kPlayout | kRecording);
+ NiceMock<MockAudioTransportAndroid> mock(kPlayout | kRecording);
std::unique_ptr<FifoAudioStream> fifo_audio_stream(
new FifoAudioStream(playout_frames_per_10ms_buffer()));
mock.HandleCallbacks(test_is_done_.get(),
@@ -1040,7 +1002,7 @@ TEST_F(AudioDeviceTest, RunPlayoutAndRecordingInFullDuplex) {
TEST_F(AudioDeviceTest, DISABLED_MeasureLoopbackLatency) {
EXPECT_EQ(record_channels(), playout_channels());
EXPECT_EQ(record_sample_rate(), playout_sample_rate());
- NiceMock<MockAudioTransport> mock(kPlayout | kRecording);
+ NiceMock<MockAudioTransportAndroid> mock(kPlayout | kRecording);
std::unique_ptr<LatencyMeasuringAudioStream> latency_audio_stream(
new LatencyMeasuringAudioStream(playout_frames_per_10ms_buffer()));
mock.HandleCallbacks(test_is_done_.get(),
« no previous file with comments | « webrtc/modules/audio_device/BUILD.gn ('k') | webrtc/modules/audio_device/include/mock_audio_transport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698