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

Side by Side Diff: media/base/test_data_util.cc

Issue 7587012: Remove mock_ffmpeg and update media unittests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments. Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
(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/path_service.h"
9
10 namespace media {
11
12 void ReadTestDataFile(const std::string& name, scoped_array<uint8>* buffer,
13 int* size) {
14 FilePath file_path;
15 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
16
17 file_path = file_path.Append(FILE_PATH_LITERAL("media"))
18 .Append(FILE_PATH_LITERAL("test"))
19 .Append(FILE_PATH_LITERAL("data"))
20 .AppendASCII(name);
21
22 int64 tmp = 0;
23 CHECK(file_util::GetFileSize(file_path, &tmp))
24 << "Failed to get file size for '" << name << "'";
25
26 int file_size = static_cast<int>(tmp);
27 buffer->reset(new uint8[file_size]);
28
29 CHECK(file_size == file_util::ReadFile(file_path,
30 reinterpret_cast<char*>(buffer->get()),
31 file_size))
32 << "Failed to read '" << name << "'";
33 *size = file_size;
34 }
35
36 void ReadTestDataFile(const std::string& name, scoped_refptr<Buffer>* buffer) {
37 scoped_array<uint8> buf;
38 int buf_size;
39 ReadTestDataFile(name, &buf, &buf_size);
40 *buffer = new DataBuffer(buf.release(), buf_size);
41 }
42
43 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698