Chromium Code Reviews

Side by Side Diff: webrtc/modules/audio_processing/aec_dump/aec_dump_unittest.cc

Issue 2865113002: AecDump implementation. (Closed)
Patch Set: Clean up of impl code. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <utility>
12
13 #include "webrtc/modules/audio_processing/aec_dump/aec_dump.h"
14
15 #include "webrtc/base/task_queue.h"
16 #include "webrtc/modules/include/module_common_types.h"
17 #include "webrtc/test/gtest.h"
18 #include "webrtc/test/testsupport/fileutils.h"
19
20 TEST(AecDumper, APICallsDoNotCrash) {
21 // Note order of initialization: Task queue has to be initialized
22 // before AecDump.
23 rtc::TaskQueue file_writer_queue("file_writer_queue");
24
25 const std::string filename =
26 webrtc::test::TempFilename(webrtc::test::OutputPath(), "aec_dump");
27
28 {
29 webrtc::AecDump aec_dump(filename, -1, &file_writer_queue);
30
31 const webrtc::AudioFrame frame;
32 aec_dump.WriteRenderStreamMessage(frame);
33
34 webrtc::AecDump::CaptureStreamInfo capture_stream_info;
35
36 capture_stream_info.AddInput(frame);
37 capture_stream_info.AddOutput(frame);
38
39 aec_dump.WriteCaptureStreamMessage(&capture_stream_info);
40
41 webrtc::InternalAPMConfig apm_config;
42 aec_dump.WriteConfig(apm_config, false);
43
44 aec_dump.WriteConfig(apm_config, true);
45
46 webrtc::InternalAPMStreamsConfig streams_config;
47 aec_dump.WriteInitMessage(streams_config);
48 }
49 // Remove file after the AecDump d-tor has finished.
50 ASSERT_EQ(0, remove(filename.c_str()));
51 }
52
53 TEST(AecDumper, WriteToFile) {
54 rtc::TaskQueue file_writer_queue("file_writer_queue");
55
56 const std::string filename =
57 webrtc::test::TempFilename(webrtc::test::OutputPath(), "aec_dump");
58
59 {
60 webrtc::AecDump aec_dump(filename, -1, &file_writer_queue);
61 const webrtc::AudioFrame frame;
62 aec_dump.WriteRenderStreamMessage(frame);
63 }
64
65 // Verify the file has been written after the AecDump d-tor has
66 // finished.
67 FILE* fid = fopen(filename.c_str(), "r");
68 ASSERT_TRUE(fid != NULL);
69
70 // Clean it up.
71 ASSERT_EQ(0, fclose(fid));
72 ASSERT_EQ(0, remove(filename.c_str()));
73 }
OLDNEW

Powered by Google App Engine