Move test utilities in media/base to media/test.

Also clean up test_data_util.cc.

Change-Id: Ic6038e072939d55fad7cc739b53ab9888b4251c1
This commit is contained in:
Kongqun Yang 2014-01-09 15:50:18 -08:00
parent faab1435ba
commit c73bfadd0e
7 changed files with 16 additions and 47 deletions

View File

@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/file_util.h"
#include "media/base/container_names.h"
#include "media/base/test_data_util.h"
#include "base/file_util.h"
#include "media/test/test_data_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media {

View File

@ -4,18 +4,10 @@
#include "media/mp4/mp4_media_parser.h"
#include <algorithm>
#include <string>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "media/base/media_sample.h"
#include "media/base/stream_info.h"
#include "media/base/test_data_util.h"
#include "media/mp4/es_descriptor.h"
#include "media/test/test_data_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media {

View File

@ -11,8 +11,8 @@
#include "media/base/muxer_options.h"
#include "media/base/status_test_util.h"
#include "media/base/stream_info.h"
#include "media/base/test_data_util.h"
#include "media/mp4/mp4_muxer.h"
#include "media/test/test_data_util.h"
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::Combine;

View File

@ -2,7 +2,7 @@
// 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 "media/test/test_data_util.h"
#include "base/file_util.h"
#include "base/logging.h"
@ -22,27 +22,9 @@ base::FilePath GetTestDataFilePath(const std::string& name) {
}
std::vector<uint8> ReadTestDataFile(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"))
.Append(FILE_PATH_LITERAL("test"))
.Append(FILE_PATH_LITERAL("data"))
.AppendASCII(name);
int64 tmp = 0;
CHECK(file_util::GetFileSize(file_path, &tmp))
<< "Failed to get file size for '" << name << "'";
int file_size = static_cast<int>(tmp);
std::vector<uint8> buffer(file_size);
CHECK_EQ(file_size,
file_util::ReadFile(
file_path, reinterpret_cast<char*>(&buffer[0]), file_size))
<< "Failed to read '" << name << "'";
return buffer;
std::string buffer;
CHECK(file_util::ReadFileToString(GetTestDataFilePath(name), &buffer));
return std::vector<uint8>(buffer.begin(), buffer.end());
}
} // namespace media

View File

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_TEST_DATA_UTIL_H_
#define MEDIA_BASE_TEST_DATA_UTIL_H_
#ifndef MEDIA_TEST_TEST_DATA_UTIL_H_
#define MEDIA_TEST_TEST_DATA_UTIL_H_
#include <string>
@ -15,14 +15,9 @@ namespace media {
// Returns a file path for a file in the media/test/data directory.
base::FilePath GetTestDataFilePath(const std::string& name);
// Reads a test file from media/test/data directory and stores it in
// a DecoderBuffer. Use DecoderBuffer vs DataBuffer to ensure no matter
// what a test does, it's safe to use FFmpeg methods.
//
// |name| - The name of the file.
// |buffer| - The contents of the file.
// Reads a test file from media/test/data directory and returns its content.
std::vector<uint8> ReadTestDataFile(const std::string& name);
} // namespace media
#endif // MEDIA_BASE_TEST_DATA_UTIL_H_
#endif // MEDIA_TEST_TEST_DATA_UTIL_H_

View File

@ -64,10 +64,9 @@
'target_name': 'media_test_support',
'type': 'static_library',
'sources': [
# TODO(kqyang): move these files to test directory.
'media/base/run_tests_with_atexit_manager.cc',
'media/base/test_data_util.cc',
'media/base/test_data_util.h',
'media/test/run_tests_with_atexit_manager.cc',
'media/test/test_data_util.cc',
'media/test/test_data_util.h',
],
'dependencies': [
'base/base.gyp:base',