| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/test_data_util.h" | 5 #include "media/base/test_data_util.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 query.append("&"); | 46 query.append("&"); |
| 47 query.append(itr->first + "=" + itr->second); | 47 query.append(itr->first + "=" + itr->second); |
| 48 } | 48 } |
| 49 return query; | 49 return query; |
| 50 } | 50 } |
| 51 | 51 |
| 52 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) { | 52 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) { |
| 53 base::FilePath file_path = GetTestDataFilePath(name); | 53 base::FilePath file_path = GetTestDataFilePath(name); |
| 54 | 54 |
| 55 int64_t tmp = 0; | 55 int64_t tmp = 0; |
| 56 CHECK(base::GetFileSize(file_path, &tmp)) | 56 // Failed to get file size for |name| |
| 57 << "Failed to get file size for '" << name << "'"; | 57 CHECK(base::GetFileSize(file_path, &tmp)); |
| 58 | 58 |
| 59 int file_size = base::checked_cast<int>(tmp); | 59 int file_size = base::checked_cast<int>(tmp); |
| 60 | 60 |
| 61 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(file_size)); | 61 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(file_size)); |
| 62 CHECK_EQ(file_size, | 62 // Failed to read |name| |
| 63 base::ReadFile( | 63 CHECK_EQ(file_size, base::ReadFile(file_path, reinterpret_cast<char*>( |
| 64 file_path, reinterpret_cast<char*>(buffer->writable_data()), | 64 buffer->writable_data()), |
| 65 file_size)) << "Failed to read '" << name << "'"; | 65 file_size)); |
| 66 | 66 |
| 67 return buffer; | 67 return buffer; |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool LookupTestKeyVector(const std::vector<uint8_t>& key_id, | 70 bool LookupTestKeyVector(const std::vector<uint8_t>& key_id, |
| 71 bool allow_rotation, | 71 bool allow_rotation, |
| 72 std::vector<uint8_t>* key) { | 72 std::vector<uint8_t>* key) { |
| 73 std::vector<uint8_t> starting_key_id(kKeyId, kKeyId + arraysize(kKeyId)); | 73 std::vector<uint8_t> starting_key_id(kKeyId, kKeyId + arraysize(kKeyId)); |
| 74 size_t rotate_limit = allow_rotation ? starting_key_id.size() : 1; | 74 size_t rotate_limit = allow_rotation ? starting_key_id.size() : 1; |
| 75 for (size_t pos = 0; pos < rotate_limit; ++pos) { | 75 for (size_t pos = 0; pos < rotate_limit; ++pos) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 90 std::vector<uint8_t> key_vector; | 90 std::vector<uint8_t> key_vector; |
| 91 bool result = | 91 bool result = |
| 92 LookupTestKeyVector(std::vector<uint8_t>(key_id.begin(), key_id.end()), | 92 LookupTestKeyVector(std::vector<uint8_t>(key_id.begin(), key_id.end()), |
| 93 allow_rotation, &key_vector); | 93 allow_rotation, &key_vector); |
| 94 if (result) | 94 if (result) |
| 95 *key = std::string(key_vector.begin(), key_vector.end()); | 95 *key = std::string(key_vector.begin(), key_vector.end()); |
| 96 return result; | 96 return result; |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace media | 99 } // namespace media |
| OLD | NEW |