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

Side by Side Diff: webrtc/modules/audio_device/test/audio_device_test_api.cc

Issue 2219653004: Remove old methods in AudioTransport, make it pass a gn build (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix compile. Created 4 years, 4 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 (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 using namespace webrtc; 47 using namespace webrtc;
48 48
49 class AudioEventObserverAPI: public AudioDeviceObserver { 49 class AudioEventObserverAPI: public AudioDeviceObserver {
50 public: 50 public:
51 AudioEventObserverAPI( 51 AudioEventObserverAPI(
52 const rtc::scoped_refptr<AudioDeviceModule>& audioDevice) 52 const rtc::scoped_refptr<AudioDeviceModule>& audioDevice)
53 : error_(kRecordingError), 53 : error_(kRecordingError),
54 warning_(kRecordingWarning), 54 warning_(kRecordingWarning),
55 audio_device_(audioDevice) {} 55 audio_device_(audioDevice) {}
56 56
57 ~AudioEventObserverAPI() {} 57 ~AudioEventObserverAPI() override {}
58 58
59 virtual void OnErrorIsReported(const ErrorCode error) { 59 void OnErrorIsReported(const ErrorCode error) override {
60 TEST_LOG("\n[*** ERROR ***] => OnErrorIsReported(%d)\n\n", error); 60 TEST_LOG("\n[*** ERROR ***] => OnErrorIsReported(%d)\n\n", error);
61 error_ = error; 61 error_ = error;
62 } 62 }
63 63
64 virtual void OnWarningIsReported(const WarningCode warning) { 64 void OnWarningIsReported(const WarningCode warning) override {
65 TEST_LOG("\n[*** WARNING ***] => OnWarningIsReported(%d)\n\n", warning); 65 TEST_LOG("\n[*** WARNING ***] => OnWarningIsReported(%d)\n\n", warning);
66 warning_ = warning; 66 warning_ = warning;
67 EXPECT_EQ(0, audio_device_->StopRecording()); 67 EXPECT_EQ(0, audio_device_->StopRecording());
68 EXPECT_EQ(0, audio_device_->StopPlayout()); 68 EXPECT_EQ(0, audio_device_->StopPlayout());
69 } 69 }
70 70
71 public: 71 public:
72 ErrorCode error_; 72 ErrorCode error_;
73 WarningCode warning_; 73 WarningCode warning_;
74 private: 74 private:
75 rtc::scoped_refptr<AudioDeviceModule> audio_device_; 75 rtc::scoped_refptr<AudioDeviceModule> audio_device_;
76 }; 76 };
77 77
78 class AudioTransportAPI: public AudioTransport { 78 class AudioTransportAPI: public AudioTransport {
79 public: 79 public:
80 AudioTransportAPI(const rtc::scoped_refptr<AudioDeviceModule>& audioDevice) 80 AudioTransportAPI(const rtc::scoped_refptr<AudioDeviceModule>& audioDevice)
81 : rec_count_(0), 81 : rec_count_(0),
82 play_count_(0) { 82 play_count_(0) {
83 } 83 }
84 84
85 ~AudioTransportAPI() {} 85 ~AudioTransportAPI() override {}
86 86
87 int32_t RecordedDataIsAvailable(const void* audioSamples, 87 int32_t RecordedDataIsAvailable(const void* audioSamples,
88 const size_t nSamples, 88 const size_t nSamples,
89 const size_t nBytesPerSample, 89 const size_t nBytesPerSample,
90 const size_t nChannels, 90 const size_t nChannels,
91 const uint32_t sampleRate, 91 const uint32_t sampleRate,
92 const uint32_t totalDelay, 92 const uint32_t totalDelay,
93 const int32_t clockSkew, 93 const int32_t clockSkew,
94 const uint32_t currentMicLevel, 94 const uint32_t currentMicLevel,
95 const bool keyPressed, 95 const bool keyPressed,
(...skipping 27 matching lines...) Expand all
123 if (nChannels == 1) { 123 if (nChannels == 1) {
124 TEST_LOG("+"); 124 TEST_LOG("+");
125 } else { 125 } else {
126 TEST_LOG("++"); 126 TEST_LOG("++");
127 } 127 }
128 } 128 }
129 nSamplesOut = 480; 129 nSamplesOut = 480;
130 return 0; 130 return 0;
131 } 131 }
132 132
133 void PushCaptureData(int voe_channel,
134 const void* audio_data,
135 int bits_per_sample,
136 int sample_rate,
137 size_t number_of_channels,
138 size_t number_of_frames) override {}
139
140 void PullRenderData(int bits_per_sample,
141 int sample_rate,
142 size_t number_of_channels,
143 size_t number_of_frames,
144 void* audio_data,
145 int64_t* elapsed_time_ms,
146 int64_t* ntp_time_ms) override {}
147
133 private: 148 private:
134 uint32_t rec_count_; 149 uint32_t rec_count_;
135 uint32_t play_count_; 150 uint32_t play_count_;
136 }; 151 };
137 152
138 class AudioDeviceAPITest: public testing::Test { 153 class AudioDeviceAPITest: public testing::Test {
139 protected: 154 protected:
140 AudioDeviceAPITest() {} 155 AudioDeviceAPITest() {}
141 156
142 virtual ~AudioDeviceAPITest() {} 157 ~AudioDeviceAPITest() override {}
143 158
144 static void SetUpTestCase() { 159 static void SetUpTestCase() {
145 process_thread_ = ProcessThread::Create("ProcessThread"); 160 process_thread_ = ProcessThread::Create("ProcessThread");
146 process_thread_->Start(); 161 process_thread_->Start();
147 162
148 // Windows: 163 // Windows:
149 // if (WEBRTC_WINDOWS_CORE_AUDIO_BUILD) 164 // if (WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
150 // user can select between default (Core) or Wave 165 // user can select between default (Core) or Wave
151 // else 166 // else
152 // user can select between default (Wave) or Wave 167 // user can select between default (Wave) or Wave
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 266 }
252 if (audio_transport_) { 267 if (audio_transport_) {
253 delete audio_transport_; 268 delete audio_transport_;
254 audio_transport_ = NULL; 269 audio_transport_ = NULL;
255 } 270 }
256 if (audio_device_) 271 if (audio_device_)
257 EXPECT_EQ(0, audio_device_.release()->Release()); 272 EXPECT_EQ(0, audio_device_.release()->Release());
258 PRINT_TEST_RESULTS; 273 PRINT_TEST_RESULTS;
259 } 274 }
260 275
261 void SetUp() { 276 void SetUp() override {
262 if (linux_alsa_) { 277 if (linux_alsa_) {
263 FAIL() << "API Test is not available on ALSA on Linux!"; 278 FAIL() << "API Test is not available on ALSA on Linux!";
264 } 279 }
265 EXPECT_EQ(0, audio_device_->Init()); 280 EXPECT_EQ(0, audio_device_->Init());
266 EXPECT_TRUE(audio_device_->Initialized()); 281 EXPECT_TRUE(audio_device_->Initialized());
267 } 282 }
268 283
269 void TearDown() { 284 void TearDown() override { EXPECT_EQ(0, audio_device_->Terminate()); }
270 EXPECT_EQ(0, audio_device_->Terminate());
271 }
272 285
273 void CheckVolume(uint32_t expected, uint32_t actual) { 286 void CheckVolume(uint32_t expected, uint32_t actual) {
274 // Mac and Windows have lower resolution on the volume settings. 287 // Mac and Windows have lower resolution on the volume settings.
275 #if defined(WEBRTC_MAC) || defined(_WIN32) 288 #if defined(WEBRTC_MAC) || defined(_WIN32)
276 int diff = abs(static_cast<int>(expected - actual)); 289 int diff = abs(static_cast<int>(expected - actual));
277 EXPECT_LE(diff, 5); 290 EXPECT_LE(diff, 5);
278 #else 291 #else
279 EXPECT_TRUE((actual == expected) || (actual == expected-1)); 292 EXPECT_TRUE((actual == expected) || (actual == expected-1));
280 #endif 293 #endif
281 } 294 }
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 // TODO(kjellander): Fix so these tests pass on Mac. 1811 // TODO(kjellander): Fix so these tests pass on Mac.
1799 #if !defined(WEBRTC_MAC) 1812 #if !defined(WEBRTC_MAC)
1800 EXPECT_EQ(0, audio_device_->InitPlayout()); 1813 EXPECT_EQ(0, audio_device_->InitPlayout());
1801 EXPECT_EQ(0, audio_device_->StartPlayout()); 1814 EXPECT_EQ(0, audio_device_->StartPlayout());
1802 #endif 1815 #endif
1803 1816
1804 EXPECT_EQ(-1, audio_device_->GetLoudspeakerStatus(&loudspeakerOn)); 1817 EXPECT_EQ(-1, audio_device_->GetLoudspeakerStatus(&loudspeakerOn));
1805 #endif 1818 #endif
1806 EXPECT_EQ(0, audio_device_->StopPlayout()); 1819 EXPECT_EQ(0, audio_device_->StopPlayout());
1807 } 1820 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/ios/audio_device_unittest_ios.cc ('k') | webrtc/modules/audio_device/test/func_test_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698