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

Unified Diff: content/renderer/media/webrtc_audio_device_unittest.cc

Issue 8558022: Expose a way for unit tests to terminate the AudioManager singleton to avoid conflicts between te... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | « no previous file | media/audio/audio_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc_audio_device_unittest.cc
===================================================================
--- content/renderer/media/webrtc_audio_device_unittest.cc (revision 110695)
+++ content/renderer/media/webrtc_audio_device_unittest.cc (working copy)
@@ -6,6 +6,7 @@
#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_manager.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"
@@ -114,9 +115,38 @@
} // end namespace
+// Utility class to delete the AudioManager
henrika (OOO until Aug 14) 2011/11/20 18:43:03 AudioManager.
tommi (sloooow) - chröme 2011/11/21 10:39:33 Done.
+class AutoAudioManagerCleanup {
+ public:
+ AutoAudioManagerCleanup() {
+ if (DeleteAndResurrectIfExists()) {
henrika (OOO until Aug 14) 2011/11/20 18:43:03 I would call it DeleteAndRessurrect(). If not, it
tommi (sloooow) - chröme 2011/11/21 10:39:33 Done. Although, FYI: The name says exactly what t
+ // In order to prevent this from happening, we sacrifice this test even
+ // though some other test must have caused this. If we don't it won't
+ // get fixed. Sorry :)
+ ADD_FAILURE()
+ << "AudioManager singleton was not cleaned up by some previous test!";
+ }
+ }
+ ~AutoAudioManagerCleanup() {
+ DeleteAndResurrectIfExists();
+ }
+
+ protected:
+ // Returns true iff the AudioManager existed and was deleted.
+ bool DeleteAndResurrectIfExists() {
+ if (AudioManager::SingletonExists()) {
+ AudioManager::Destroy(NULL);
+ AudioManager::Resurrect();
+ return true;
+ }
+ return false;
+ }
+};
+
// Basic test that instantiates and initializes an instance of
// WebRtcAudioDeviceImpl.
TEST_F(WebRTCAudioDeviceTest, Construct) {
henrika (OOO until Aug 14) 2011/11/20 18:43:03 Why is this the only test were we don't add if (I
tommi (sloooow) - chröme 2011/11/21 10:39:33 This is the only test that can currently pass on t
+ AutoAudioManagerCleanup audio_manager_cleanup;
AudioUtilNoHardware audio_util(48000.0, 48000.0);
SetAudioUtilCallback(&audio_util);
scoped_refptr<WebRtcAudioDeviceImpl> audio_device(
@@ -139,6 +169,8 @@
// verify that streaming starts correctly.
// Disabled when running headless since the bots don't have the required config.
TEST_F(WebRTCAudioDeviceTest, StartPlayout) {
+ AutoAudioManagerCleanup audio_manager_cleanup;
+
if (IsRunningHeadless())
return;
@@ -208,6 +240,8 @@
// that the audio capturing starts as it should.
// Disabled when running headless since the bots don't have the required config.
TEST_F(WebRTCAudioDeviceTest, StartRecording) {
+ AutoAudioManagerCleanup audio_manager_cleanup;
+
if (IsRunningHeadless())
return;
@@ -272,6 +306,8 @@
// Uses WebRtcAudioDeviceImpl to play a local wave file.
// Disabled when running headless since the bots don't have the required config.
TEST_F(WebRTCAudioDeviceTest, PlayLocalFile) {
+ AutoAudioManagerCleanup audio_manager_cleanup;
+
if (IsRunningHeadless())
return;
@@ -332,6 +368,8 @@
// TODO(henrika): improve quality by using a wideband codec, enabling noise-
// suppressions and perhaps also the digital AGC.
TEST_F(WebRTCAudioDeviceTest, FullDuplexAudio) {
+ AutoAudioManagerCleanup audio_manager_cleanup;
+
if (IsRunningHeadless())
return;
@@ -341,6 +379,8 @@
OnSetAudioStreamPlaying(_, 1, true));
EXPECT_CALL(media_observer(),
OnSetAudioStreamStatus(_, 1, StrEq("closed")));
+ EXPECT_CALL(media_observer(),
+ OnDeleteAudioStream(_, 1)).Times(AnyNumber());
AudioUtil audio_util;
SetAudioUtilCallback(&audio_util);
« no previous file with comments | « no previous file | media/audio/audio_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698