OLD | NEW |
(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_factory.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 std::unique_ptr<webrtc::AecDump> aec_dump = |
| 30 webrtc::AecDumpFactory::Create(filename, -1, &file_writer_queue); |
| 31 |
| 32 const webrtc::AudioFrame frame; |
| 33 aec_dump->WriteRenderStreamMessage(frame); |
| 34 |
| 35 aec_dump->AddCaptureStreamInput(frame); |
| 36 aec_dump->AddCaptureStreamOutput(frame); |
| 37 |
| 38 aec_dump->WriteCaptureStreamMessage(); |
| 39 |
| 40 webrtc::InternalAPMConfig apm_config; |
| 41 aec_dump->WriteConfig(apm_config); |
| 42 |
| 43 webrtc::InternalAPMStreamsConfig streams_config; |
| 44 aec_dump->WriteInitMessage(streams_config); |
| 45 } |
| 46 // Remove file after the AecDump d-tor has finished. |
| 47 ASSERT_EQ(0, remove(filename.c_str())); |
| 48 } |
| 49 |
| 50 TEST(AecDumper, WriteToFile) { |
| 51 rtc::TaskQueue file_writer_queue("file_writer_queue"); |
| 52 |
| 53 const std::string filename = |
| 54 webrtc::test::TempFilename(webrtc::test::OutputPath(), "aec_dump"); |
| 55 |
| 56 { |
| 57 std::unique_ptr<webrtc::AecDump> aec_dump = |
| 58 webrtc::AecDumpFactory::Create(filename, -1, &file_writer_queue); |
| 59 const webrtc::AudioFrame frame; |
| 60 aec_dump->WriteRenderStreamMessage(frame); |
| 61 } |
| 62 |
| 63 // Verify the file has been written after the AecDump d-tor has |
| 64 // finished. |
| 65 FILE* fid = fopen(filename.c_str(), "r"); |
| 66 ASSERT_TRUE(fid != NULL); |
| 67 |
| 68 // Clean it up. |
| 69 ASSERT_EQ(0, fclose(fid)); |
| 70 ASSERT_EQ(0, remove(filename.c_str())); |
| 71 } |
OLD | NEW |