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

Unified Diff: webrtc/modules/audio_processing/transient/file_utils_unittest.cc

Issue 1688553002: Cleanup temporary files created by tests. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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 | « webrtc/base/optionsfile_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_processing/transient/file_utils_unittest.cc
diff --git a/webrtc/modules/audio_processing/transient/file_utils_unittest.cc b/webrtc/modules/audio_processing/transient/file_utils_unittest.cc
index b8d532f3a4f7230c005cac6d8e7f164469b90594..065354228ea119d2d4491ca98d83ec41d95a9636 100644
--- a/webrtc/modules/audio_processing/transient/file_utils_unittest.cc
+++ b/webrtc/modules/audio_processing/transient/file_utils_unittest.cc
@@ -12,6 +12,7 @@
#include <string.h>
#include <string>
+#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
@@ -45,6 +46,25 @@ class TransientFileUtilsTest: public ::testing::Test {
kTestFileNamef(
test::ResourcePath("audio_processing/transient/float-utils",
"dat")) {}
+
+ ~TransientFileUtilsTest() override {
+ CleanupTempFiles();
+ }
+
+ std::string CreateTempFilename(const std::string& dir,
+ const std::string& prefix) {
+ std::string filename = test::TempFilename(dir, prefix);
+ temp_filenames_.push_back(filename);
+ return filename;
+ }
+
+ void CleanupTempFiles() {
+ for (const std::string& filename : temp_filenames_) {
+ remove(filename.c_str());
+ }
+ temp_filenames_.clear();
+ }
+
// This file (used in some tests) contains binary data. The data correspond to
// the double representation of the constants: Pi, E, and the Avogadro's
// Number;
@@ -56,6 +76,9 @@ class TransientFileUtilsTest: public ::testing::Test {
// Number;
// appended in that order.
const std::string kTestFileNamef;
+
+ // List of temporary filenames created by CreateTempFilename.
+ std::vector<std::string> temp_filenames_;
};
#if defined(WEBRTC_IOS)
@@ -358,7 +381,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadDoubleBufferFromFile) {
TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) {
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
- std::string kOutFileName = test::TempFilename(test::OutputPath(),
+ std::string kOutFileName = CreateTempFilename(test::OutputPath(),
"utils_test");
file->OpenFile(kOutFileName.c_str(),
@@ -405,7 +428,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) {
TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) {
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
- std::string kOutFileName = test::TempFilename(test::OutputPath(),
+ std::string kOutFileName = CreateTempFilename(test::OutputPath(),
"utils_test");
file->OpenFile(kOutFileName.c_str(),
@@ -452,7 +475,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) {
TEST_F(TransientFileUtilsTest, MAYBE_WriteDoubleBufferToFile) {
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
- std::string kOutFileName = test::TempFilename(test::OutputPath(),
+ std::string kOutFileName = CreateTempFilename(test::OutputPath(),
"utils_test");
file->OpenFile(kOutFileName.c_str(),
« no previous file with comments | « webrtc/base/optionsfile_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698