OLD | NEW |
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 |
11 #include <math.h> | 11 #include <math.h> |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 #include <string.h> | 13 #include <string.h> |
14 | 14 |
| 15 #include <memory> |
| 16 |
15 #include "webrtc/modules/audio_device/test/audio_device_test_defines.h" | 17 #include "webrtc/modules/audio_device/test/audio_device_test_defines.h" |
16 | 18 |
17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "webrtc/test/testsupport/fileutils.h" | 20 #include "webrtc/test/testsupport/fileutils.h" |
19 | 21 |
20 #include "webrtc/modules/audio_device/audio_device_config.h" | 22 #include "webrtc/modules/audio_device/audio_device_config.h" |
21 #include "webrtc/modules/audio_device/audio_device_impl.h" | 23 #include "webrtc/modules/audio_device/audio_device_impl.h" |
22 #include "webrtc/system_wrappers/include/sleep.h" | 24 #include "webrtc/system_wrappers/include/sleep.h" |
23 | 25 |
24 // Helper functions | 26 // Helper functions |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 uint32_t play_count_; | 135 uint32_t play_count_; |
134 }; | 136 }; |
135 | 137 |
136 class AudioDeviceAPITest: public testing::Test { | 138 class AudioDeviceAPITest: public testing::Test { |
137 protected: | 139 protected: |
138 AudioDeviceAPITest() {} | 140 AudioDeviceAPITest() {} |
139 | 141 |
140 virtual ~AudioDeviceAPITest() {} | 142 virtual ~AudioDeviceAPITest() {} |
141 | 143 |
142 static void SetUpTestCase() { | 144 static void SetUpTestCase() { |
143 process_thread_ = ProcessThread::Create("ProcessThread"); | 145 process_thread_ = |
| 146 rtc::ScopedToUnique(ProcessThread::Create("ProcessThread")); |
144 process_thread_->Start(); | 147 process_thread_->Start(); |
145 | 148 |
146 // Windows: | 149 // Windows: |
147 // if (WEBRTC_WINDOWS_CORE_AUDIO_BUILD) | 150 // if (WEBRTC_WINDOWS_CORE_AUDIO_BUILD) |
148 // user can select between default (Core) or Wave | 151 // user can select between default (Core) or Wave |
149 // else | 152 // else |
150 // user can select between default (Wave) or Wave | 153 // user can select between default (Wave) or Wave |
151 const int32_t kId = 444; | 154 const int32_t kId = 444; |
152 | 155 |
153 #if defined(_WIN32) | 156 #if defined(_WIN32) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 296 } |
294 | 297 |
295 void CheckInitialRecordingStates() { | 298 void CheckInitialRecordingStates() { |
296 EXPECT_FALSE(audio_device_->RecordingIsInitialized()); | 299 EXPECT_FALSE(audio_device_->RecordingIsInitialized()); |
297 EXPECT_FALSE(audio_device_->Recording()); | 300 EXPECT_FALSE(audio_device_->Recording()); |
298 EXPECT_FALSE(audio_device_->MicrophoneIsInitialized()); | 301 EXPECT_FALSE(audio_device_->MicrophoneIsInitialized()); |
299 } | 302 } |
300 | 303 |
301 // TODO(henrika): Get rid of globals. | 304 // TODO(henrika): Get rid of globals. |
302 static bool linux_alsa_; | 305 static bool linux_alsa_; |
303 static rtc::scoped_ptr<ProcessThread> process_thread_; | 306 static std::unique_ptr<ProcessThread> process_thread_; |
304 static AudioDeviceModule* audio_device_; | 307 static AudioDeviceModule* audio_device_; |
305 static AudioTransportAPI* audio_transport_; | 308 static AudioTransportAPI* audio_transport_; |
306 static AudioEventObserverAPI* event_observer_; | 309 static AudioEventObserverAPI* event_observer_; |
307 }; | 310 }; |
308 | 311 |
309 // Must be initialized like this to handle static SetUpTestCase() above. | 312 // Must be initialized like this to handle static SetUpTestCase() above. |
310 bool AudioDeviceAPITest::linux_alsa_ = false; | 313 bool AudioDeviceAPITest::linux_alsa_ = false; |
311 rtc::scoped_ptr<ProcessThread> AudioDeviceAPITest::process_thread_; | 314 std::unique_ptr<ProcessThread> AudioDeviceAPITest::process_thread_; |
312 AudioDeviceModule* AudioDeviceAPITest::audio_device_ = NULL; | 315 AudioDeviceModule* AudioDeviceAPITest::audio_device_ = NULL; |
313 AudioTransportAPI* AudioDeviceAPITest::audio_transport_ = NULL; | 316 AudioTransportAPI* AudioDeviceAPITest::audio_transport_ = NULL; |
314 AudioEventObserverAPI* AudioDeviceAPITest::event_observer_ = NULL; | 317 AudioEventObserverAPI* AudioDeviceAPITest::event_observer_ = NULL; |
315 | 318 |
316 TEST_F(AudioDeviceAPITest, RegisterEventObserver) { | 319 TEST_F(AudioDeviceAPITest, RegisterEventObserver) { |
317 event_observer_ = new AudioEventObserverAPI(audio_device_); | 320 event_observer_ = new AudioEventObserverAPI(audio_device_); |
318 EXPECT_EQ(0, audio_device_->RegisterEventObserver(NULL)); | 321 EXPECT_EQ(0, audio_device_->RegisterEventObserver(NULL)); |
319 EXPECT_EQ(0, audio_device_->RegisterEventObserver(event_observer_)); | 322 EXPECT_EQ(0, audio_device_->RegisterEventObserver(event_observer_)); |
320 EXPECT_EQ(0, audio_device_->RegisterEventObserver(NULL)); | 323 EXPECT_EQ(0, audio_device_->RegisterEventObserver(NULL)); |
321 } | 324 } |
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 // TODO(kjellander): Fix so these tests pass on Mac. | 1807 // TODO(kjellander): Fix so these tests pass on Mac. |
1805 #if !defined(WEBRTC_MAC) | 1808 #if !defined(WEBRTC_MAC) |
1806 EXPECT_EQ(0, audio_device_->InitPlayout()); | 1809 EXPECT_EQ(0, audio_device_->InitPlayout()); |
1807 EXPECT_EQ(0, audio_device_->StartPlayout()); | 1810 EXPECT_EQ(0, audio_device_->StartPlayout()); |
1808 #endif | 1811 #endif |
1809 | 1812 |
1810 EXPECT_EQ(-1, audio_device_->GetLoudspeakerStatus(&loudspeakerOn)); | 1813 EXPECT_EQ(-1, audio_device_->GetLoudspeakerStatus(&loudspeakerOn)); |
1811 #endif | 1814 #endif |
1812 EXPECT_EQ(0, audio_device_->StopPlayout()); | 1815 EXPECT_EQ(0, audio_device_->StopPlayout()); |
1813 } | 1816 } |
OLD | NEW |