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

Side by Side Diff: webrtc/modules/audio_processing/transient/wpd_tree_unittest.cc

Issue 2054373002: FileWrapper[Impl] modifications and actually remove the "Impl" class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix use of ASSERT instead of ASSERT_TRUE in test Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 std::unique_ptr<FileWrapper> matlab_files_data[kLeaves]; 88 std::unique_ptr<FileWrapper> matlab_files_data[kLeaves];
89 std::unique_ptr<FileWrapper> out_files_data[kLeaves]; 89 std::unique_ptr<FileWrapper> out_files_data[kLeaves];
90 90
91 for (int i = 0; i < kLeaves; ++i) { 91 for (int i = 0; i < kLeaves; ++i) {
92 // Matlab files. 92 // Matlab files.
93 matlab_files_data[i].reset(FileWrapper::Create()); 93 matlab_files_data[i].reset(FileWrapper::Create());
94 94
95 std::ostringstream matlab_stream; 95 std::ostringstream matlab_stream;
96 matlab_stream << "audio_processing/transient/wpd" << i; 96 matlab_stream << "audio_processing/transient/wpd" << i;
97 std::string matlab_string = test::ResourcePath(matlab_stream.str(), "dat"); 97 std::string matlab_string = test::ResourcePath(matlab_stream.str(), "dat");
98 matlab_files_data[i]->OpenFile(matlab_string.c_str(), 98 matlab_files_data[i]->OpenFile(matlab_string.c_str(), true); // Read only.
99 true, // Read only.
100 false, // No loop.
101 false); // No text.
102 99
103 bool file_opened = matlab_files_data[i]->Open(); 100 bool file_opened = matlab_files_data[i]->is_open();
104 ASSERT_TRUE(file_opened) << "File could not be opened.\n" << matlab_string; 101 ASSERT_TRUE(file_opened) << "File could not be opened.\n" << matlab_string;
105 102
106 // Out files. 103 // Out files.
107 out_files_data[i].reset(FileWrapper::Create()); 104 out_files_data[i].reset(FileWrapper::Create());
108 105
109 std::ostringstream out_stream; 106 std::ostringstream out_stream;
110 out_stream << test::OutputPath() << "wpd_" << i << ".out"; 107 out_stream << test::OutputPath() << "wpd_" << i << ".out";
111 std::string out_string = out_stream.str(); 108 std::string out_string = out_stream.str();
112 109
113 out_files_data[i]->OpenFile(out_string.c_str(), 110 out_files_data[i]->OpenFile(out_string.c_str(), false); // Write mode.
114 false, // Write mode.
115 false, // No loop.
116 false); // No text.
117 111
118 file_opened = out_files_data[i]->Open(); 112 file_opened = out_files_data[i]->is_open();
119 ASSERT_TRUE(file_opened) << "File could not be opened.\n" << out_string; 113 ASSERT_TRUE(file_opened) << "File could not be opened.\n" << out_string;
120 } 114 }
121 115
122 // Prepare the test file. 116 // Prepare the test file.
123 std::string test_file_name = test::ResourcePath( 117 std::string test_file_name = test::ResourcePath(
124 "audio_processing/transient/ajm-macbook-1-spke16m", "pcm"); 118 "audio_processing/transient/ajm-macbook-1-spke16m", "pcm");
125 119
126 std::unique_ptr<FileWrapper> test_file(FileWrapper::Create()); 120 std::unique_ptr<FileWrapper> test_file(FileWrapper::Create());
127 121
128 test_file->OpenFile(test_file_name.c_str(), 122 test_file->OpenFile(test_file_name.c_str(), true); // Read only.
129 true, // Read only.
130 false, // No loop.
131 false); // No text.
132 123
133 bool file_opened = test_file->Open(); 124 bool file_opened = test_file->is_open();
134 ASSERT_TRUE(file_opened) << "File could not be opened.\n" << test_file_name; 125 ASSERT_TRUE(file_opened) << "File could not be opened.\n" << test_file_name;
135 126
136 float test_buffer[kTestBufferSize]; 127 float test_buffer[kTestBufferSize];
137 128
138 // Only the first frames of the audio file are tested. The matlab files also 129 // Only the first frames of the audio file are tested. The matlab files also
139 // only contains information about the first frames. 130 // only contains information about the first frames.
140 const size_t kMaxFramesToTest = 100; 131 const size_t kMaxFramesToTest = 100;
141 const float kTolerance = 0.03f; 132 const float kTolerance = 0.03f;
142 133
143 size_t frames_read = 0; 134 size_t frames_read = 0;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // Close all matlab and out files. 184 // Close all matlab and out files.
194 for (int i = 0; i < kLeaves; ++i) { 185 for (int i = 0; i < kLeaves; ++i) {
195 matlab_files_data[i]->CloseFile(); 186 matlab_files_data[i]->CloseFile();
196 out_files_data[i]->CloseFile(); 187 out_files_data[i]->CloseFile();
197 } 188 }
198 189
199 test_file->CloseFile(); 190 test_file->CloseFile();
200 } 191 }
201 192
202 } // namespace webrtc 193 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/transient/transient_detector_unittest.cc ('k') | webrtc/modules/media_file/media_file_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698