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.
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/test/test_data_util.h"
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2015-07-22 23:40:45 +00:00
|
|
|
#include "packager/base/files/file_util.h"
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/base/logging.h"
|
|
|
|
#include "packager/base/path_service.h"
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-09-24 01:35:40 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
base::FilePath GetTestDataFilePath(const std::string& name) {
|
|
|
|
base::FilePath file_path;
|
|
|
|
CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
|
|
|
|
|
2014-10-01 20:44:41 +00:00
|
|
|
file_path = file_path.Append(FILE_PATH_LITERAL("packager"))
|
|
|
|
.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;
|
|
|
|
}
|
|
|
|
|
2017-05-31 18:14:11 +00:00
|
|
|
base::FilePath GetAppTestDataFilePath(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("packager"))
|
|
|
|
.Append(FILE_PATH_LITERAL("app"))
|
|
|
|
.Append(FILE_PATH_LITERAL("test"))
|
|
|
|
.Append(FILE_PATH_LITERAL("testdata"))
|
|
|
|
.AppendASCII(name);
|
|
|
|
return file_path;
|
|
|
|
}
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint8_t> ReadTestDataFile(const std::string& name) {
|
2014-01-09 23:50:18 +00:00
|
|
|
std::string buffer;
|
2014-02-26 23:55:01 +00:00
|
|
|
CHECK(base::ReadFileToString(GetTestDataFilePath(name), &buffer));
|
2014-09-30 21:52:21 +00:00
|
|
|
return std::vector<uint8_t>(buffer.begin(), buffer.end());
|
2013-09-24 01:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|