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

Unified Diff: media/audio/audio_manager_unittest.cc

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Code review. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/audio_output_proxy_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_manager_unittest.cc
diff --git a/media/audio/audio_manager_unittest.cc b/media/audio/audio_manager_unittest.cc
index 7635e645160c283a868ffffa39d56cf9c0cae6e1..1af0db799652111bcc706fe7001c1f253d17dbef 100644
--- a/media/audio/audio_manager_unittest.cc
+++ b/media/audio/audio_manager_unittest.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/environment.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/waitable_event.h"
@@ -22,6 +23,7 @@
#include "media/audio/audio_unittest_util.h"
#include "media/audio/fake_audio_log_factory.h"
#include "media/audio/fake_audio_manager.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(USE_ALSA)
@@ -48,6 +50,7 @@
namespace media {
namespace {
+
template <typename T>
struct TestAudioManagerFactory {
static ScopedAudioManagerPtr Create(AudioLogFactory* audio_log_factory) {
@@ -552,6 +555,24 @@ TEST_F(AudioManagerTest, GetAssociatedOutputDeviceID) {
}
#endif // defined(USE_CRAS)
+// Mock class to verify enable and disable debug recording calls.
+class MockAudioDebugRecordingManager : public AudioDebugRecordingManager {
+ public:
+ MockAudioDebugRecordingManager(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner)
+ : AudioDebugRecordingManager(std::move(task_runner),
+ std::move(file_task_runner)) {}
+
+ ~MockAudioDebugRecordingManager() override {}
+
+ MOCK_METHOD1(EnableDebugRecording, void(const base::FilePath&));
+ MOCK_METHOD0(DisableDebugRecording, void());
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockAudioDebugRecordingManager);
+};
+
class TestAudioManager : public FakeAudioManager {
// For testing the default implementation of GetGroupId(Input|Output)
// input$i is associated to output$i, if both exist.
@@ -592,6 +613,13 @@ class TestAudioManager : public FakeAudioManager {
device_names->emplace_back("Output 4", "output4");
device_names->push_front(AudioDeviceName::CreateDefault());
}
+
+ std::unique_ptr<AudioDebugRecordingManager> CreateAudioDebugRecordingManager(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) override {
+ return base::MakeUnique<MockAudioDebugRecordingManager>(
+ std::move(task_runner), std::move(file_task_runner));
+ }
};
TEST_F(AudioManagerTest, GroupId) {
@@ -617,4 +645,31 @@ TEST_F(AudioManagerTest, GroupId) {
EXPECT_NE(inputs[1].group_id, outputs[3].group_id);
}
+TEST_F(AudioManagerTest, AudioDebugRecording) {
+ CreateAudioManagerForTesting<TestAudioManager>();
+
+ AudioManagerBase* audio_manager_base =
+ static_cast<AudioManagerBase*>(audio_manager_.get());
+
+ // Initialize is normally done in AudioManager::Create(), but since we don't
+ // use that in this test, we need to initialize here.
+ audio_manager_->InitializeOutputDebugRecording(
+ audio_manager_->GetTaskRunner());
+
+ MockAudioDebugRecordingManager* mock_debug_recording_manager =
+ static_cast<MockAudioDebugRecordingManager*>(
+ audio_manager_base->debug_recording_manager_.get());
+ ASSERT_TRUE(mock_debug_recording_manager);
+
+ EXPECT_CALL(*mock_debug_recording_manager, DisableDebugRecording());
+ audio_manager_->DisableOutputDebugRecording();
+
+ base::FilePath file_path(FILE_PATH_LITERAL("path"));
+ EXPECT_CALL(*mock_debug_recording_manager, EnableDebugRecording(file_path));
+ audio_manager_->EnableOutputDebugRecording(file_path);
+
+ EXPECT_CALL(*mock_debug_recording_manager, DisableDebugRecording());
+ audio_manager_->DisableOutputDebugRecording();
+}
+
} // namespace media
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/audio_output_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698