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

Unified Diff: webrtc/modules/audio_processing/test/audio_processing_unittest.cc

Issue 1413483003: Added option to specify a maximum file size when recording an AEC dump. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Initial version Created 5 years, 2 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
Index: webrtc/modules/audio_processing/test/audio_processing_unittest.cc
diff --git a/webrtc/modules/audio_processing/test/audio_processing_unittest.cc b/webrtc/modules/audio_processing/test/audio_processing_unittest.cc
index 3ebea13a4552f6104b331464a166e3e4341b74dc..1c20e3c8834828a6a86d4519bc0cfd67bc4441ff 100644
--- a/webrtc/modules/audio_processing/test/audio_processing_unittest.cc
+++ b/webrtc/modules/audio_processing/test/audio_processing_unittest.cc
@@ -388,7 +388,8 @@ class ApmTest : public ::testing::Test {
int AnalyzeReverseStreamChooser(Format format);
void ProcessDebugDump(const std::string& in_filename,
const std::string& out_filename,
- Format format);
+ Format format,
+ int max_size_bytes);
void VerifyDebugDumpTest(Format format);
const std::string output_path_;
@@ -1711,7 +1712,8 @@ TEST_F(ApmTest, SplittingFilter) {
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
void ApmTest::ProcessDebugDump(const std::string& in_filename,
const std::string& out_filename,
- Format format) {
+ Format format,
+ int max_size_bytes) {
FILE* in_file = fopen(in_filename.c_str(), "rb");
ASSERT_TRUE(in_file != NULL);
audioproc::Event event_msg;
@@ -1739,7 +1741,12 @@ void ApmTest::ProcessDebugDump(const std::string& in_filename,
if (first_init) {
// StartDebugRecording() writes an additional init message. Don't start
// recording until after the first init to avoid the extra message.
- EXPECT_NOERR(apm_->StartDebugRecording(out_filename.c_str()));
+ if (max_size_bytes != -1) {
+ EXPECT_NOERR(
+ apm_->StartDebugRecording(out_filename.c_str(), max_size_bytes));
+ } else {
+ EXPECT_NOERR(apm_->StartDebugRecording(out_filename.c_str()));
+ }
first_init = false;
}
@@ -1812,34 +1819,52 @@ void ApmTest::VerifyDebugDumpTest(Format format) {
test::OutputPath(), std::string("ref") + format_string + "_aecdump");
const std::string out_filename = test::TempFilename(
test::OutputPath(), std::string("out") + format_string + "_aecdump");
+ const std::string limited_filename = test::TempFilename(
+ test::OutputPath(), std::string("limited") + format_string + "_aecdump");
+ const size_t logging_limit_bytes = 100000;
EnableAllComponents();
- ProcessDebugDump(in_filename, ref_filename, format);
- ProcessDebugDump(ref_filename, out_filename, format);
+ ProcessDebugDump(in_filename, ref_filename, format, -1);
+ ProcessDebugDump(ref_filename, out_filename, format, -1);
+ ProcessDebugDump(ref_filename, limited_filename, format, logging_limit_bytes);
FILE* ref_file = fopen(ref_filename.c_str(), "rb");
FILE* out_file = fopen(out_filename.c_str(), "rb");
+ FILE* limited_file = fopen(limited_filename.c_str(), "rb");
ASSERT_TRUE(ref_file != NULL);
ASSERT_TRUE(out_file != NULL);
+ ASSERT_TRUE(limited_file != NULL);
rtc::scoped_ptr<uint8_t[]> ref_bytes;
rtc::scoped_ptr<uint8_t[]> out_bytes;
+ rtc::scoped_ptr<uint8_t[]> limited_bytes;
size_t ref_size = ReadMessageBytesFromFile(ref_file, &ref_bytes);
size_t out_size = ReadMessageBytesFromFile(out_file, &out_bytes);
+ size_t limited_size = ReadMessageBytesFromFile(limited_file, &limited_bytes);
size_t bytes_read = 0;
+ size_t bytes_read_limited = 0;
while (ref_size > 0 && out_size > 0) {
bytes_read += ref_size;
+ bytes_read_limited += limited_size;
EXPECT_EQ(ref_size, out_size);
+ EXPECT_GE(ref_size, limited_size);
EXPECT_EQ(0, memcmp(ref_bytes.get(), out_bytes.get(), ref_size));
+ EXPECT_EQ(0, memcmp(ref_bytes.get(), limited_bytes.get(), limited_size));
ref_size = ReadMessageBytesFromFile(ref_file, &ref_bytes);
out_size = ReadMessageBytesFromFile(out_file, &out_bytes);
+ limited_size = ReadMessageBytesFromFile(limited_file, &limited_bytes);
}
EXPECT_GT(bytes_read, 0u);
+ EXPECT_GT(bytes_read_limited, 0u);
+ EXPECT_LE(bytes_read_limited, logging_limit_bytes);
hlundin-webrtc 2015/10/30 08:02:21 Should you maybe test that the actual file size en
ivoc 2015/11/05 13:14:46 I added an appropriate lower bound.
EXPECT_NE(0, feof(ref_file));
EXPECT_NE(0, feof(out_file));
+ EXPECT_NE(0, feof(limited_file));
ASSERT_EQ(0, fclose(ref_file));
ASSERT_EQ(0, fclose(out_file));
+ ASSERT_EQ(0, fclose(limited_file));
remove(ref_filename.c_str());
remove(out_filename.c_str());
+ remove(limited_filename.c_str());
}
TEST_F(ApmTest, VerifyDebugDumpInt) {

Powered by Google App Engine
This is Rietveld 408576698