2013-09-24 01:35:40 +00:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "media/base/test_data_util.h"
|
|
|
|
|
|
|
|
#include "base/file_util.h"
|
|
|
|
#include "base/logging.h"
|
|
|
|
#include "base/path_service.h"
|
|
|
|
|
|
|
|
namespace media {
|
|
|
|
|
|
|
|
base::FilePath GetTestDataFilePath(const std::string& name) {
|
|
|
|
base::FilePath file_path;
|
|
|
|
CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
|
|
|
|
|
|
|
|
file_path = file_path.Append(FILE_PATH_LITERAL("media"))
|
2013-11-12 20:32:44 +00:00
|
|
|
.Append(FILE_PATH_LITERAL("test"))
|
|
|
|
.Append(FILE_PATH_LITERAL("data"))
|
|
|
|
.AppendASCII(name);
|
2013-09-24 01:35:40 +00:00
|
|
|
return file_path;
|
|
|
|
}
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
std::vector<uint8> ReadTestDataFile(const std::string& name) {
|
2013-09-24 01:35:40 +00:00
|
|
|
base::FilePath file_path;
|
|
|
|
CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
|
|
|
|
|
|
|
|
file_path = file_path.Append(FILE_PATH_LITERAL("media"))
|
2013-11-12 20:32:44 +00:00
|
|
|
.Append(FILE_PATH_LITERAL("test"))
|
|
|
|
.Append(FILE_PATH_LITERAL("data"))
|
|
|
|
.AppendASCII(name);
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
int64 tmp = 0;
|
|
|
|
CHECK(file_util::GetFileSize(file_path, &tmp))
|
|
|
|
<< "Failed to get file size for '" << name << "'";
|
|
|
|
|
|
|
|
int file_size = static_cast<int>(tmp);
|
2013-09-24 04:17:12 +00:00
|
|
|
std::vector<uint8> buffer(file_size);
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
CHECK_EQ(file_size,
|
|
|
|
file_util::ReadFile(
|
2013-11-12 20:32:44 +00:00
|
|
|
file_path, reinterpret_cast<char*>(&buffer[0]), file_size))
|
|
|
|
<< "Failed to read '" << name << "'";
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace media
|