Chromium Code Reviews| Index: content/renderer/media/webrtc_audio_device_unittest.cc |
| =================================================================== |
| --- content/renderer/media/webrtc_audio_device_unittest.cc (revision 0) |
| +++ content/renderer/media/webrtc_audio_device_unittest.cc (working copy) |
| @@ -0,0 +1,66 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/test/test_timeouts.h" |
| +#include "content/renderer/media/webrtc_audio_device_impl.h" |
| +#include "content/test/webrtc_audio_device_test.h" |
| +#include "media/audio/audio_util.h" |
| +#include "testing/gmock/include/gmock/gmock.h" |
| +#include "third_party/webrtc/voice_engine/main/interface/voe_audio_processing.h" |
| +#include "third_party/webrtc/voice_engine/main/interface/voe_base.h" |
| +#include "third_party/webrtc/voice_engine/main/interface/voe_file.h" |
| +#include "third_party/webrtc/voice_engine/main/interface/voe_network.h" |
| + |
| +using testing::_; |
| +using testing::InvokeWithoutArgs; |
| +using testing::Return; |
| +using testing::StrEq; |
| + |
| +namespace { |
| + |
| +ACTION_P(QuitMessageLoop, loop_or_proxy) { |
| + loop_or_proxy->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| +} |
| + |
| +class AudioUtil : public AudioUtilInterface { |
| + public: |
| + virtual double GetAudioHardwareSampleRate() OVERRIDE { |
| + return media::GetAudioHardwareSampleRate(); |
| + } |
| + virtual double GetAudioInputHardwareSampleRate() OVERRIDE { |
| + return media::GetAudioInputHardwareSampleRate(); |
| + } |
| +}; |
| + |
| +} // end namespace |
| + |
| +// Basic test that instantiates and initializes an instance of |
| +// WebRtcAudioDeviceImpl. |
| +TEST_F(WebRTCAudioDeviceTest, Construct) { |
| + AudioUtil audio_util; |
| + set_audio_util_callback(&audio_util); |
|
henrika (OOO until Aug 14)
2011/11/04 10:35:12
Where can I find the definition of set_audio_util_
tommi (sloooow) - chröme
2011/11/07 10:27:28
webrtc_audio_device_test.h@130
|
| + scoped_refptr<WebRtcAudioDeviceImpl> audio_device( |
| + new WebRtcAudioDeviceImpl()); |
| + audio_device->SetSessionId(1); |
| + |
| + WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); |
|
henrika (OOO until Aug 14)
2011/11/04 10:35:12
Why not ensure that engine is valid (not NULL) her
tommi (sloooow) - chröme
2011/11/07 10:27:28
Done.
|
| + |
| + ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); |
| + int err = base->Init(audio_device); |
| + EXPECT_EQ(0, err); |
| +} |
| + |
| +// Plays a local file. This test usually takes just under a minute to run |
| +// and requires an audio card to work, so disabled by default. |
| +TEST_F(WebRTCAudioDeviceTest, DISABLED_PlayLocalFileLong) { |
| + AudioUtil audio_util; |
| + set_audio_util_callback(&audio_util); |
| + PlayLocalFile(0); |
|
henrika (OOO until Aug 14)
2011/11/04 10:35:12
I have never seen this before where a unit test ca
henrika (OOO until Aug 14)
2011/11/04 10:35:12
Add comment about meaning of '0' here.
tommi (sloooow) - chröme
2011/11/07 10:27:28
The reason is because two tests use the same code.
|
| +} |
| + |
| +TEST_F(WebRTCAudioDeviceTest, PlayLocalFile) { |
| + AudioUtil audio_util; |
| + set_audio_util_callback(&audio_util); |
| + PlayLocalFile(TestTimeouts::action_timeout_ms()); |
| +} |
| Property changes on: content/renderer/media/webrtc_audio_device_unittest.cc |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| ## -0,0 +1 ## |
| +LF |