Clean-up: Removes gfx::FontList::GetStringWidth(text).
[chromium-blink-merge.git] / media / base / test_data_util.cc
blob386617e006b6067e40922c45c5b376cc6792c267
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
3 // found in the LICENSE file.
5 #include "media/base/test_data_util.h"
7 #include "base/file_util.h"
8 #include "base/logging.h"
9 #include "base/path_service.h"
10 #include "media/base/decoder_buffer.h"
12 namespace media {
14 base::FilePath GetTestDataFilePath(const std::string& name) {
15 base::FilePath file_path;
16 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
18 file_path = file_path.Append(FILE_PATH_LITERAL("media"))
19 .Append(FILE_PATH_LITERAL("test")).Append(FILE_PATH_LITERAL("data"))
20 .AppendASCII(name);
21 return file_path;
24 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) {
25 base::FilePath file_path;
26 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
28 file_path = file_path.Append(FILE_PATH_LITERAL("media"))
29 .Append(FILE_PATH_LITERAL("test")).Append(FILE_PATH_LITERAL("data"))
30 .AppendASCII(name);
32 int64 tmp = 0;
33 CHECK(base::GetFileSize(file_path, &tmp))
34 << "Failed to get file size for '" << name << "'";
36 int file_size = static_cast<int>(tmp);
38 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(file_size));
39 CHECK_EQ(file_size,
40 base::ReadFile(
41 file_path, reinterpret_cast<char*>(buffer->writable_data()),
42 file_size)) << "Failed to read '" << name << "'";
44 return buffer;
47 } // namespace media