| OLD | NEW |
| 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 |
| 11 #include "webrtc/modules/audio_processing/transient/file_utils.h" | 11 #include "webrtc/modules/audio_processing/transient/file_utils.h" |
| 12 | 12 |
| 13 #include <string.h> | 13 #include <string.h> |
| 14 #include <string> | 14 #include <string> |
| 15 | 15 |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
| 18 #include "webrtc/system_wrappers/include/file_wrapper.h" | 18 #include "webrtc/system_wrappers/include/file_wrapper.h" |
| 19 #include "webrtc/test/testsupport/fileutils.h" | 19 #include "webrtc/test/testsupport/fileutils.h" |
| 20 #include "webrtc/test/testsupport/gtest_disable.h" | |
| 21 #include "webrtc/typedefs.h" | 20 #include "webrtc/typedefs.h" |
| 22 | 21 |
| 23 namespace webrtc { | 22 namespace webrtc { |
| 24 | 23 |
| 25 static const uint8_t kPiBytesf[4] = {0xDB, 0x0F, 0x49, 0x40}; | 24 static const uint8_t kPiBytesf[4] = {0xDB, 0x0F, 0x49, 0x40}; |
| 26 static const uint8_t kEBytesf[4] = {0x54, 0xF8, 0x2D, 0x40}; | 25 static const uint8_t kEBytesf[4] = {0x54, 0xF8, 0x2D, 0x40}; |
| 27 static const uint8_t kAvogadroBytesf[4] = {0x2F, 0x0C, 0xFF, 0x66}; | 26 static const uint8_t kAvogadroBytesf[4] = {0x2F, 0x0C, 0xFF, 0x66}; |
| 28 | 27 |
| 29 static const uint8_t kPiBytes[8] = | 28 static const uint8_t kPiBytes[8] = |
| 30 {0x18, 0x2D, 0x44, 0x54, 0xFB, 0x21, 0x09, 0x40}; | 29 {0x18, 0x2D, 0x44, 0x54, 0xFB, 0x21, 0x09, 0x40}; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 52 // appended in that order. | 51 // appended in that order. |
| 53 const std::string kTestFileName; | 52 const std::string kTestFileName; |
| 54 | 53 |
| 55 // This file (used in some tests) contains binary data. The data correspond to | 54 // This file (used in some tests) contains binary data. The data correspond to |
| 56 // the float representation of the constants: Pi, E, and the Avogadro's | 55 // the float representation of the constants: Pi, E, and the Avogadro's |
| 57 // Number; | 56 // Number; |
| 58 // appended in that order. | 57 // appended in that order. |
| 59 const std::string kTestFileNamef; | 58 const std::string kTestFileNamef; |
| 60 }; | 59 }; |
| 61 | 60 |
| 62 TEST_F(TransientFileUtilsTest, DISABLED_ON_IOS(ConvertByteArrayToFloat)) { | 61 #if defined(WEBRTC_IOS) |
| 62 TEST_F(TransientFileUtilsTest, DISABLED_ConvertByteArrayToFloat) { |
| 63 #else |
| 64 TEST_F(TransientFileUtilsTest, ConvertByteArrayToFloat) { |
| 65 #endif |
| 63 float value = 0.0; | 66 float value = 0.0; |
| 64 | 67 |
| 65 EXPECT_EQ(0, ConvertByteArrayToFloat(kPiBytesf, &value)); | 68 EXPECT_EQ(0, ConvertByteArrayToFloat(kPiBytesf, &value)); |
| 66 EXPECT_FLOAT_EQ(kPi, value); | 69 EXPECT_FLOAT_EQ(kPi, value); |
| 67 | 70 |
| 68 EXPECT_EQ(0, ConvertByteArrayToFloat(kEBytesf, &value)); | 71 EXPECT_EQ(0, ConvertByteArrayToFloat(kEBytesf, &value)); |
| 69 EXPECT_FLOAT_EQ(kE, value); | 72 EXPECT_FLOAT_EQ(kE, value); |
| 70 | 73 |
| 71 EXPECT_EQ(0, ConvertByteArrayToFloat(kAvogadroBytesf, &value)); | 74 EXPECT_EQ(0, ConvertByteArrayToFloat(kAvogadroBytesf, &value)); |
| 72 EXPECT_FLOAT_EQ(kAvogadro, value); | 75 EXPECT_FLOAT_EQ(kAvogadro, value); |
| 73 } | 76 } |
| 74 | 77 |
| 75 TEST_F(TransientFileUtilsTest, DISABLED_ON_IOS(ConvertByteArrayToDouble)) { | 78 #if defined(WEBRTC_IOS) |
| 79 TEST_F(TransientFileUtilsTest, DISABLED_ConvertByteArrayToDouble) { |
| 80 #else |
| 81 TEST_F(TransientFileUtilsTest, ConvertByteArrayToDouble) { |
| 82 #endif |
| 76 double value = 0.0; | 83 double value = 0.0; |
| 77 | 84 |
| 78 EXPECT_EQ(0, ConvertByteArrayToDouble(kPiBytes, &value)); | 85 EXPECT_EQ(0, ConvertByteArrayToDouble(kPiBytes, &value)); |
| 79 EXPECT_DOUBLE_EQ(kPi, value); | 86 EXPECT_DOUBLE_EQ(kPi, value); |
| 80 | 87 |
| 81 EXPECT_EQ(0, ConvertByteArrayToDouble(kEBytes, &value)); | 88 EXPECT_EQ(0, ConvertByteArrayToDouble(kEBytes, &value)); |
| 82 EXPECT_DOUBLE_EQ(kE, value); | 89 EXPECT_DOUBLE_EQ(kE, value); |
| 83 | 90 |
| 84 EXPECT_EQ(0, ConvertByteArrayToDouble(kAvogadroBytes, &value)); | 91 EXPECT_EQ(0, ConvertByteArrayToDouble(kAvogadroBytes, &value)); |
| 85 EXPECT_DOUBLE_EQ(kAvogadro, value); | 92 EXPECT_DOUBLE_EQ(kAvogadro, value); |
| 86 } | 93 } |
| 87 | 94 |
| 88 TEST_F(TransientFileUtilsTest, DISABLED_ON_IOS(ConvertFloatToByteArray)) { | 95 #if defined(WEBRTC_IOS) |
| 96 TEST_F(TransientFileUtilsTest, DISABLED_ConvertFloatToByteArray) { |
| 97 #else |
| 98 TEST_F(TransientFileUtilsTest, ConvertFloatToByteArray) { |
| 99 #endif |
| 89 rtc::scoped_ptr<uint8_t[]> bytes(new uint8_t[4]); | 100 rtc::scoped_ptr<uint8_t[]> bytes(new uint8_t[4]); |
| 90 | 101 |
| 91 EXPECT_EQ(0, ConvertFloatToByteArray(kPi, bytes.get())); | 102 EXPECT_EQ(0, ConvertFloatToByteArray(kPi, bytes.get())); |
| 92 EXPECT_EQ(0, memcmp(bytes.get(), kPiBytesf, 4)); | 103 EXPECT_EQ(0, memcmp(bytes.get(), kPiBytesf, 4)); |
| 93 | 104 |
| 94 EXPECT_EQ(0, ConvertFloatToByteArray(kE, bytes.get())); | 105 EXPECT_EQ(0, ConvertFloatToByteArray(kE, bytes.get())); |
| 95 EXPECT_EQ(0, memcmp(bytes.get(), kEBytesf, 4)); | 106 EXPECT_EQ(0, memcmp(bytes.get(), kEBytesf, 4)); |
| 96 | 107 |
| 97 EXPECT_EQ(0, ConvertFloatToByteArray(kAvogadro, bytes.get())); | 108 EXPECT_EQ(0, ConvertFloatToByteArray(kAvogadro, bytes.get())); |
| 98 EXPECT_EQ(0, memcmp(bytes.get(), kAvogadroBytesf, 4)); | 109 EXPECT_EQ(0, memcmp(bytes.get(), kAvogadroBytesf, 4)); |
| 99 } | 110 } |
| 100 | 111 |
| 101 TEST_F(TransientFileUtilsTest, DISABLED_ON_IOS(ConvertDoubleToByteArray)) { | 112 #if defined(WEBRTC_IOS) |
| 113 TEST_F(TransientFileUtilsTest, DISABLED_ConvertDoubleToByteArray) { |
| 114 #else |
| 115 TEST_F(TransientFileUtilsTest, ConvertDoubleToByteArray) { |
| 116 #endif |
| 102 rtc::scoped_ptr<uint8_t[]> bytes(new uint8_t[8]); | 117 rtc::scoped_ptr<uint8_t[]> bytes(new uint8_t[8]); |
| 103 | 118 |
| 104 EXPECT_EQ(0, ConvertDoubleToByteArray(kPi, bytes.get())); | 119 EXPECT_EQ(0, ConvertDoubleToByteArray(kPi, bytes.get())); |
| 105 EXPECT_EQ(0, memcmp(bytes.get(), kPiBytes, 8)); | 120 EXPECT_EQ(0, memcmp(bytes.get(), kPiBytes, 8)); |
| 106 | 121 |
| 107 EXPECT_EQ(0, ConvertDoubleToByteArray(kE, bytes.get())); | 122 EXPECT_EQ(0, ConvertDoubleToByteArray(kE, bytes.get())); |
| 108 EXPECT_EQ(0, memcmp(bytes.get(), kEBytes, 8)); | 123 EXPECT_EQ(0, memcmp(bytes.get(), kEBytes, 8)); |
| 109 | 124 |
| 110 EXPECT_EQ(0, ConvertDoubleToByteArray(kAvogadro, bytes.get())); | 125 EXPECT_EQ(0, ConvertDoubleToByteArray(kAvogadro, bytes.get())); |
| 111 EXPECT_EQ(0, memcmp(bytes.get(), kAvogadroBytes, 8)); | 126 EXPECT_EQ(0, memcmp(bytes.get(), kAvogadroBytes, 8)); |
| 112 } | 127 } |
| 113 | 128 |
| 114 TEST_F(TransientFileUtilsTest, DISABLED_ON_IOS(ReadInt16BufferFromFile)) { | 129 #if defined(WEBRTC_IOS) |
| 130 TEST_F(TransientFileUtilsTest, DISABLED_ReadInt16BufferFromFile) { |
| 131 #else |
| 132 TEST_F(TransientFileUtilsTest, ReadInt16BufferFromFile) { |
| 133 #endif |
| 115 std::string test_filename = kTestFileName; | 134 std::string test_filename = kTestFileName; |
| 116 | 135 |
| 117 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); | 136 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); |
| 118 | 137 |
| 119 file->OpenFile(test_filename.c_str(), | 138 file->OpenFile(test_filename.c_str(), |
| 120 true, // Read only. | 139 true, // Read only. |
| 121 true, // Loop. | 140 true, // Loop. |
| 122 false); // No text. | 141 false); // No text. |
| 123 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" | 142 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" |
| 124 << kTestFileName.c_str(); | 143 << kTestFileName.c_str(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 142 buffer.reset(new int16_t[kBufferLenghtLargerThanFile]); | 161 buffer.reset(new int16_t[kBufferLenghtLargerThanFile]); |
| 143 EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(), | 162 EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(), |
| 144 kBufferLenghtLargerThanFile, | 163 kBufferLenghtLargerThanFile, |
| 145 buffer.get())); | 164 buffer.get())); |
| 146 EXPECT_EQ(11544, buffer[0]); | 165 EXPECT_EQ(11544, buffer[0]); |
| 147 EXPECT_EQ(22377, buffer[4]); | 166 EXPECT_EQ(22377, buffer[4]); |
| 148 EXPECT_EQ(16389, buffer[7]); | 167 EXPECT_EQ(16389, buffer[7]); |
| 149 EXPECT_EQ(17631, buffer[kBufferLength - 1]); | 168 EXPECT_EQ(17631, buffer[kBufferLength - 1]); |
| 150 } | 169 } |
| 151 | 170 |
| 152 TEST_F(TransientFileUtilsTest, | 171 #if defined(WEBRTC_IOS) |
| 153 DISABLED_ON_IOS(ReadInt16FromFileToFloatBuffer)) { | 172 TEST_F(TransientFileUtilsTest, DISABLED_ReadInt16FromFileToFloatBuffer) { |
| 173 #else |
| 174 TEST_F(TransientFileUtilsTest, ReadInt16FromFileToFloatBuffer) { |
| 175 #endif |
| 154 std::string test_filename = kTestFileName; | 176 std::string test_filename = kTestFileName; |
| 155 | 177 |
| 156 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); | 178 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); |
| 157 | 179 |
| 158 file->OpenFile(test_filename.c_str(), | 180 file->OpenFile(test_filename.c_str(), |
| 159 true, // Read only. | 181 true, // Read only. |
| 160 true, // Loop. | 182 true, // Loop. |
| 161 false); // No text. | 183 false); // No text. |
| 162 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" | 184 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" |
| 163 << kTestFileName.c_str(); | 185 << kTestFileName.c_str(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 184 EXPECT_EQ(kBufferLength, | 206 EXPECT_EQ(kBufferLength, |
| 185 ReadInt16FromFileToFloatBuffer(file.get(), | 207 ReadInt16FromFileToFloatBuffer(file.get(), |
| 186 kBufferLenghtLargerThanFile, | 208 kBufferLenghtLargerThanFile, |
| 187 buffer.get())); | 209 buffer.get())); |
| 188 EXPECT_DOUBLE_EQ(11544, buffer[0]); | 210 EXPECT_DOUBLE_EQ(11544, buffer[0]); |
| 189 EXPECT_DOUBLE_EQ(22377, buffer[4]); | 211 EXPECT_DOUBLE_EQ(22377, buffer[4]); |
| 190 EXPECT_DOUBLE_EQ(16389, buffer[7]); | 212 EXPECT_DOUBLE_EQ(16389, buffer[7]); |
| 191 EXPECT_DOUBLE_EQ(17631, buffer[kBufferLength - 1]); | 213 EXPECT_DOUBLE_EQ(17631, buffer[kBufferLength - 1]); |
| 192 } | 214 } |
| 193 | 215 |
| 194 TEST_F(TransientFileUtilsTest, | 216 #if defined(WEBRTC_IOS) |
| 195 DISABLED_ON_IOS(ReadInt16FromFileToDoubleBuffer)) { | 217 TEST_F(TransientFileUtilsTest, DISABLED_ReadInt16FromFileToDoubleBuffer) { |
| 218 #else |
| 219 TEST_F(TransientFileUtilsTest, ReadInt16FromFileToDoubleBuffer) { |
| 220 #endif |
| 196 std::string test_filename = kTestFileName; | 221 std::string test_filename = kTestFileName; |
| 197 | 222 |
| 198 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); | 223 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); |
| 199 | 224 |
| 200 file->OpenFile(test_filename.c_str(), | 225 file->OpenFile(test_filename.c_str(), |
| 201 true, // Read only. | 226 true, // Read only. |
| 202 true, // Loop. | 227 true, // Loop. |
| 203 false); // No text. | 228 false); // No text. |
| 204 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" | 229 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" |
| 205 << kTestFileName.c_str(); | 230 << kTestFileName.c_str(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 225 EXPECT_EQ(kBufferLength, | 250 EXPECT_EQ(kBufferLength, |
| 226 ReadInt16FromFileToDoubleBuffer(file.get(), | 251 ReadInt16FromFileToDoubleBuffer(file.get(), |
| 227 kBufferLenghtLargerThanFile, | 252 kBufferLenghtLargerThanFile, |
| 228 buffer.get())); | 253 buffer.get())); |
| 229 EXPECT_DOUBLE_EQ(11544, buffer[0]); | 254 EXPECT_DOUBLE_EQ(11544, buffer[0]); |
| 230 EXPECT_DOUBLE_EQ(22377, buffer[4]); | 255 EXPECT_DOUBLE_EQ(22377, buffer[4]); |
| 231 EXPECT_DOUBLE_EQ(16389, buffer[7]); | 256 EXPECT_DOUBLE_EQ(16389, buffer[7]); |
| 232 EXPECT_DOUBLE_EQ(17631, buffer[kBufferLength - 1]); | 257 EXPECT_DOUBLE_EQ(17631, buffer[kBufferLength - 1]); |
| 233 } | 258 } |
| 234 | 259 |
| 235 TEST_F(TransientFileUtilsTest, DISABLED_ON_IOS(ReadFloatBufferFromFile)) { | 260 #if defined(WEBRTC_IOS) |
| 261 TEST_F(TransientFileUtilsTest, DISABLED_ReadFloatBufferFromFile) { |
| 262 #else |
| 263 TEST_F(TransientFileUtilsTest, ReadFloatBufferFromFile) { |
| 264 #endif |
| 236 std::string test_filename = kTestFileNamef; | 265 std::string test_filename = kTestFileNamef; |
| 237 | 266 |
| 238 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); | 267 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); |
| 239 | 268 |
| 240 file->OpenFile(test_filename.c_str(), | 269 file->OpenFile(test_filename.c_str(), |
| 241 true, // Read only. | 270 true, // Read only. |
| 242 true, // Loop. | 271 true, // Loop. |
| 243 false); // No text. | 272 false); // No text. |
| 244 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" | 273 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" |
| 245 << kTestFileNamef.c_str(); | 274 << kTestFileNamef.c_str(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 262 const size_t kBufferLenghtLargerThanFile = kBufferLength * 2; | 291 const size_t kBufferLenghtLargerThanFile = kBufferLength * 2; |
| 263 buffer.reset(new float[kBufferLenghtLargerThanFile]); | 292 buffer.reset(new float[kBufferLenghtLargerThanFile]); |
| 264 EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(), | 293 EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(), |
| 265 kBufferLenghtLargerThanFile, | 294 kBufferLenghtLargerThanFile, |
| 266 buffer.get())); | 295 buffer.get())); |
| 267 EXPECT_FLOAT_EQ(kPi, buffer[0]); | 296 EXPECT_FLOAT_EQ(kPi, buffer[0]); |
| 268 EXPECT_FLOAT_EQ(kE, buffer[1]); | 297 EXPECT_FLOAT_EQ(kE, buffer[1]); |
| 269 EXPECT_FLOAT_EQ(kAvogadro, buffer[2]); | 298 EXPECT_FLOAT_EQ(kAvogadro, buffer[2]); |
| 270 } | 299 } |
| 271 | 300 |
| 272 TEST_F(TransientFileUtilsTest, DISABLED_ON_IOS(ReadDoubleBufferFromFile)) { | 301 #if defined(WEBRTC_IOS) |
| 302 TEST_F(TransientFileUtilsTest, DISABLED_ReadDoubleBufferFromFile) { |
| 303 #else |
| 304 TEST_F(TransientFileUtilsTest, ReadDoubleBufferFromFile) { |
| 305 #endif |
| 273 std::string test_filename = kTestFileName; | 306 std::string test_filename = kTestFileName; |
| 274 | 307 |
| 275 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); | 308 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); |
| 276 | 309 |
| 277 file->OpenFile(test_filename.c_str(), | 310 file->OpenFile(test_filename.c_str(), |
| 278 true, // Read only. | 311 true, // Read only. |
| 279 true, // Loop. | 312 true, // Loop. |
| 280 false); // No text. | 313 false); // No text. |
| 281 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" | 314 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" |
| 282 << kTestFileName.c_str(); | 315 << kTestFileName.c_str(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 299 const size_t kBufferLenghtLargerThanFile = kBufferLength * 2; | 332 const size_t kBufferLenghtLargerThanFile = kBufferLength * 2; |
| 300 buffer.reset(new double[kBufferLenghtLargerThanFile]); | 333 buffer.reset(new double[kBufferLenghtLargerThanFile]); |
| 301 EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(), | 334 EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(), |
| 302 kBufferLenghtLargerThanFile, | 335 kBufferLenghtLargerThanFile, |
| 303 buffer.get())); | 336 buffer.get())); |
| 304 EXPECT_DOUBLE_EQ(kPi, buffer[0]); | 337 EXPECT_DOUBLE_EQ(kPi, buffer[0]); |
| 305 EXPECT_DOUBLE_EQ(kE, buffer[1]); | 338 EXPECT_DOUBLE_EQ(kE, buffer[1]); |
| 306 EXPECT_DOUBLE_EQ(kAvogadro, buffer[2]); | 339 EXPECT_DOUBLE_EQ(kAvogadro, buffer[2]); |
| 307 } | 340 } |
| 308 | 341 |
| 309 TEST_F(TransientFileUtilsTest, DISABLED_ON_IOS(WriteInt16BufferToFile)) { | 342 #if defined(WEBRTC_IOS) |
| 343 TEST_F(TransientFileUtilsTest, DISABLED_WriteInt16BufferToFile) { |
| 344 #else |
| 345 TEST_F(TransientFileUtilsTest, WriteInt16BufferToFile) { |
| 346 #endif |
| 310 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); | 347 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); |
| 311 | 348 |
| 312 std::string kOutFileName = test::TempFilename(test::OutputPath(), | 349 std::string kOutFileName = test::TempFilename(test::OutputPath(), |
| 313 "utils_test"); | 350 "utils_test"); |
| 314 | 351 |
| 315 file->OpenFile(kOutFileName.c_str(), | 352 file->OpenFile(kOutFileName.c_str(), |
| 316 false, // Write mode. | 353 false, // Write mode. |
| 317 false, // No loop. | 354 false, // No loop. |
| 318 false); // No text. | 355 false); // No text. |
| 319 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" | 356 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 341 << kOutFileName.c_str(); | 378 << kOutFileName.c_str(); |
| 342 | 379 |
| 343 EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(), | 380 EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(), |
| 344 kBufferLength, | 381 kBufferLength, |
| 345 read_buffer.get())); | 382 read_buffer.get())); |
| 346 EXPECT_EQ(0, memcmp(written_buffer.get(), | 383 EXPECT_EQ(0, memcmp(written_buffer.get(), |
| 347 read_buffer.get(), | 384 read_buffer.get(), |
| 348 kBufferLength * sizeof(written_buffer[0]))); | 385 kBufferLength * sizeof(written_buffer[0]))); |
| 349 } | 386 } |
| 350 | 387 |
| 351 TEST_F(TransientFileUtilsTest, DISABLED_ON_IOS(WriteFloatBufferToFile)) { | 388 #if defined(WEBRTC_IOS) |
| 389 TEST_F(TransientFileUtilsTest, DISABLED_WriteFloatBufferToFile) { |
| 390 #else |
| 391 TEST_F(TransientFileUtilsTest, WriteFloatBufferToFile) { |
| 392 #endif |
| 352 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); | 393 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); |
| 353 | 394 |
| 354 std::string kOutFileName = test::TempFilename(test::OutputPath(), | 395 std::string kOutFileName = test::TempFilename(test::OutputPath(), |
| 355 "utils_test"); | 396 "utils_test"); |
| 356 | 397 |
| 357 file->OpenFile(kOutFileName.c_str(), | 398 file->OpenFile(kOutFileName.c_str(), |
| 358 false, // Write mode. | 399 false, // Write mode. |
| 359 false, // No loop. | 400 false, // No loop. |
| 360 false); // No text. | 401 false); // No text. |
| 361 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" | 402 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 383 << kOutFileName.c_str(); | 424 << kOutFileName.c_str(); |
| 384 | 425 |
| 385 EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(), | 426 EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(), |
| 386 kBufferLength, | 427 kBufferLength, |
| 387 read_buffer.get())); | 428 read_buffer.get())); |
| 388 EXPECT_EQ(0, memcmp(written_buffer.get(), | 429 EXPECT_EQ(0, memcmp(written_buffer.get(), |
| 389 read_buffer.get(), | 430 read_buffer.get(), |
| 390 kBufferLength * sizeof(written_buffer[0]))); | 431 kBufferLength * sizeof(written_buffer[0]))); |
| 391 } | 432 } |
| 392 | 433 |
| 393 TEST_F(TransientFileUtilsTest, DISABLED_ON_IOS(WriteDoubleBufferToFile)) { | 434 #if defined(WEBRTC_IOS) |
| 435 TEST_F(TransientFileUtilsTest, DISABLED_WriteDoubleBufferToFile) { |
| 436 #else |
| 437 TEST_F(TransientFileUtilsTest, WriteDoubleBufferToFile) { |
| 438 #endif |
| 394 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); | 439 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); |
| 395 | 440 |
| 396 std::string kOutFileName = test::TempFilename(test::OutputPath(), | 441 std::string kOutFileName = test::TempFilename(test::OutputPath(), |
| 397 "utils_test"); | 442 "utils_test"); |
| 398 | 443 |
| 399 file->OpenFile(kOutFileName.c_str(), | 444 file->OpenFile(kOutFileName.c_str(), |
| 400 false, // Write mode. | 445 false, // Write mode. |
| 401 false, // No loop. | 446 false, // No loop. |
| 402 false); // No text. | 447 false); // No text. |
| 403 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" | 448 ASSERT_TRUE(file->Open()) << "File could not be opened:\n" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 425 << kOutFileName.c_str(); | 470 << kOutFileName.c_str(); |
| 426 | 471 |
| 427 EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(), | 472 EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(), |
| 428 kBufferLength, | 473 kBufferLength, |
| 429 read_buffer.get())); | 474 read_buffer.get())); |
| 430 EXPECT_EQ(0, memcmp(written_buffer.get(), | 475 EXPECT_EQ(0, memcmp(written_buffer.get(), |
| 431 read_buffer.get(), | 476 read_buffer.get(), |
| 432 kBufferLength * sizeof(written_buffer[0]))); | 477 kBufferLength * sizeof(written_buffer[0]))); |
| 433 } | 478 } |
| 434 | 479 |
| 435 TEST_F(TransientFileUtilsTest, DISABLED_ON_IOS(ExpectedErrorReturnValues)) { | 480 #if defined(WEBRTC_IOS) |
| 481 TEST_F(TransientFileUtilsTest, DISABLED_ExpectedErrorReturnValues) { |
| 482 #else |
| 483 TEST_F(TransientFileUtilsTest, ExpectedErrorReturnValues) { |
| 484 #endif |
| 436 std::string test_filename = kTestFileName; | 485 std::string test_filename = kTestFileName; |
| 437 | 486 |
| 438 double value; | 487 double value; |
| 439 rtc::scoped_ptr<int16_t[]> int16_buffer(new int16_t[1]); | 488 rtc::scoped_ptr<int16_t[]> int16_buffer(new int16_t[1]); |
| 440 rtc::scoped_ptr<double[]> double_buffer(new double[1]); | 489 rtc::scoped_ptr<double[]> double_buffer(new double[1]); |
| 441 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); | 490 rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create()); |
| 442 | 491 |
| 443 EXPECT_EQ(-1, ConvertByteArrayToDouble(NULL, &value)); | 492 EXPECT_EQ(-1, ConvertByteArrayToDouble(NULL, &value)); |
| 444 EXPECT_EQ(-1, ConvertByteArrayToDouble(kPiBytes, NULL)); | 493 EXPECT_EQ(-1, ConvertByteArrayToDouble(kPiBytes, NULL)); |
| 445 | 494 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 EXPECT_EQ(0u, WriteInt16BufferToFile(file.get(), 1, NULL)); | 528 EXPECT_EQ(0u, WriteInt16BufferToFile(file.get(), 1, NULL)); |
| 480 EXPECT_EQ(0u, WriteInt16BufferToFile(file.get(), 0, int16_buffer.get())); | 529 EXPECT_EQ(0u, WriteInt16BufferToFile(file.get(), 0, int16_buffer.get())); |
| 481 | 530 |
| 482 EXPECT_EQ(0u, WriteDoubleBufferToFile(NULL, 1, double_buffer.get())); | 531 EXPECT_EQ(0u, WriteDoubleBufferToFile(NULL, 1, double_buffer.get())); |
| 483 EXPECT_EQ(0u, WriteDoubleBufferToFile(file.get(), 1, NULL)); | 532 EXPECT_EQ(0u, WriteDoubleBufferToFile(file.get(), 1, NULL)); |
| 484 EXPECT_EQ(0u, WriteDoubleBufferToFile(file.get(), 0, double_buffer.get())); | 533 EXPECT_EQ(0u, WriteDoubleBufferToFile(file.get(), 0, double_buffer.get())); |
| 485 } | 534 } |
| 486 | 535 |
| 487 } // namespace webrtc | 536 } // namespace webrtc |
| 488 | 537 |
| OLD | NEW |