OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "media/base/test_data_util.h" | |
6 | |
7 #include "base/file_util.h" | |
8 #include "base/logging.h" | |
9 #include "base/path_service.h" | |
10 | |
11 namespace media { | |
12 | |
13 void ReadTestDataFile(const std::string& name, scoped_array<uint8>* buffer, | |
14 int* size) { | |
15 FilePath file_path; | |
16 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path)); | |
17 | |
18 file_path = file_path.Append(FILE_PATH_LITERAL("media")) | |
19 .Append(FILE_PATH_LITERAL("test")) | |
20 .Append(FILE_PATH_LITERAL("data")) | |
21 .AppendASCII(name); | |
22 | |
23 int64 tmp = 0; | |
24 CHECK(file_util::GetFileSize(file_path, &tmp)) | |
25 << "Failed to get file size for '" << name << "'"; | |
26 | |
27 int file_size = static_cast<int>(tmp); | |
28 buffer->reset(new uint8[file_size]); | |
29 | |
30 CHECK(file_size == file_util::ReadFile(file_path, | |
31 reinterpret_cast<char*>(buffer->get()), | |
32 file_size)) | |
33 << "Failed to read '" << name << "'"; | |
34 *size = file_size; | |
35 } | |
36 | |
37 void ReadTestDataFile(const std::string& name, scoped_refptr<Buffer>* buffer) { | |
38 scoped_array<uint8> buf; | |
39 int buf_size; | |
40 ReadTestDataFile(name, &buf, &buf_size); | |
41 *buffer = new DataBuffer(buf.release(), buf_size); | |
42 } | |
43 | |
44 } // namespace media | |
OLD | NEW |