Remove (D)CHECK_OK and usage of MemoryMappedFile

Change-Id: Ifb46a0fe063dfe8fdd770d830f9fb7bf2cf31901
This commit is contained in:
KongQun Yang 2014-10-07 14:41:40 -07:00
parent 8ffb41df76
commit 9158f4a543
6 changed files with 23 additions and 44 deletions

View File

@ -160,12 +160,6 @@ class Status {
extern std::ostream& operator<<(std::ostream& os, const Status& x); extern std::ostream& operator<<(std::ostream& os, const Status& x);
// Status success comparison.
// This is better than CHECK((val).ok()) because the embedded
// error string gets printed by the CHECK_EQ.
#define CHECK_OK(val) CHECK_EQ(Status::OK, (val))
#define DCHECK_OK(val) DCHECK_EQ(Status::OK, (val))
} // namespace media } // namespace media
} // namespace edash_packager } // namespace edash_packager

View File

@ -41,16 +41,6 @@ TEST(Status, ConstructorOK) {
CheckStatus(Status(error::OK, "msg"), error::OK, ""); CheckStatus(Status(error::OK, "msg"), error::OK, "");
} }
TEST(Status, CheckOK) {
CHECK_OK(Status());
}
TEST(Status, CheckOKDeath) {
Status status(error::UNKNOWN, "Status Unknown");
ASSERT_DEATH(CHECK_OK(status), "Status Unknown");
ASSERT_DEATH(CHECK_OK(status) << "Foo1234", "Foo1234");
}
TEST(Status, SetError) { TEST(Status, SetError) {
Status status; Status status;
status.SetError(error::CANCELLED, "message"); status.SetError(error::CANCELLED, "message");

View File

@ -4,10 +4,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "packager/base/command_line.h"
#include "packager/base/files/memory_mapped_file.h"
#include "packager/base/logging.h" #include "packager/base/logging.h"
#include "packager/base/path_service.h" #include "packager/base/stl_util.h"
#include "packager/base/strings/string_number_conversions.h" #include "packager/base/strings/string_number_conversions.h"
#include "packager/media/test/test_data_util.h" #include "packager/media/test/test_data_util.h"
#include "packager/media/filters/h264_parser.h" #include "packager/media/filters/h264_parser.h"
@ -16,16 +14,13 @@ namespace edash_packager {
namespace media { namespace media {
TEST(H264ParserTest, StreamFileParsing) { TEST(H264ParserTest, StreamFileParsing) {
base::FilePath file_path = GetTestDataFilePath("test-25fps.h264"); std::vector<uint8_t> buffer = ReadTestDataFile("test-25fps.h264");
// Number of NALUs in the test stream to be parsed. // Number of NALUs in the test stream to be parsed.
int num_nalus = 759; int num_nalus = 759;
base::MemoryMappedFile stream;
ASSERT_TRUE(stream.Initialize(file_path))
<< "Couldn't open stream file: " << file_path.MaybeAsASCII();
H264Parser parser; H264Parser parser;
parser.SetStream(stream.data(), stream.length()); parser.SetStream(vector_as_array(&buffer), buffer.size());
// Parse until the end of stream/unsupported stream/error in stream is found. // Parse until the end of stream/unsupported stream/error in stream is found.
int num_parsed_nalus = 0; int num_parsed_nalus = 0;

View File

@ -8,10 +8,8 @@
#include <vector> #include <vector>
#include "packager/base/bind.h" #include "packager/base/bind.h"
#include "packager/base/command_line.h"
#include "packager/base/files/memory_mapped_file.h"
#include "packager/base/logging.h" #include "packager/base/logging.h"
#include "packager/base/path_service.h" #include "packager/base/stl_util.h"
#include "packager/media/base/media_sample.h" #include "packager/media/base/media_sample.h"
#include "packager/media/base/timestamp.h" #include "packager/media/base/timestamp.h"
#include "packager/media/filters/h264_parser.h" #include "packager/media/filters/h264_parser.h"
@ -150,19 +148,17 @@ class EsParserH264Test : public testing::Test {
}; };
void EsParserH264Test::LoadStream(const char* filename) { void EsParserH264Test::LoadStream(const char* filename) {
base::FilePath file_path = GetTestDataFilePath(filename); std::vector<uint8_t> buffer = ReadTestDataFile(filename);
base::MemoryMappedFile stream_without_aud;
ASSERT_TRUE(stream_without_aud.Initialize(file_path))
<< "Couldn't open stream file: " << file_path.MaybeAsASCII();
// The input file does not have AUDs. // The input file does not have AUDs.
std::vector<Packet> access_units_without_aud = GetAccessUnits( std::vector<Packet> access_units_without_aud =
stream_without_aud.data(), stream_without_aud.length()); GetAccessUnits(vector_as_array(&buffer), buffer.size());
ASSERT_GT(access_units_without_aud.size(), 0u); ASSERT_GT(access_units_without_aud.size(), 0u);
AppendAUD(stream_without_aud.data(), stream_without_aud.length(), AppendAUD(vector_as_array(&buffer),
buffer.size(),
access_units_without_aud, access_units_without_aud,
stream_, access_units_); stream_,
access_units_);
} }
void EsParserH264Test::ProcessPesPackets( void EsParserH264Test::ProcessPesPackets(

View File

@ -32,21 +32,24 @@ const uint32_t kVideoResolution = 0x00480000; // 72 dpi.
const uint16_t kVideoFrameCount = 1; const uint16_t kVideoFrameCount = 1;
const uint16_t kVideoDepth = 0x0018; const uint16_t kVideoDepth = 0x0018;
// Utility functions to check if the 64bit integers can fit in 32bit integer.
bool IsFitIn32Bits(uint64_t a) { bool IsFitIn32Bits(uint64_t a) {
return a <= std::numeric_limits<uint32_t>::max(); return a <= std::numeric_limits<uint32_t>::max();
} }
bool IsFitIn32Bits(int64_t a) { bool IsFitIn32Bits(int64_t a) {
return a <= std::numeric_limits<int32_t>::max() && return a <= std::numeric_limits<int32_t>::max() &&
a >= std::numeric_limits<int32_t>::min(); a >= std::numeric_limits<int32_t>::min();
} }
bool IsFitIn32Bits(uint64_t a, uint64_t b) {
return IsFitIn32Bits(a) && IsFitIn32Bits(b); template <typename T1, typename T2>
bool IsFitIn32Bits(T1 a1, T2 a2) {
return IsFitIn32Bits(a1) && IsFitIn32Bits(a2);
} }
bool IsFitIn32Bits(uint64_t a, int64_t b) {
return IsFitIn32Bits(a) && IsFitIn32Bits(b); template <typename T1, typename T2, typename T3>
} bool IsFitIn32Bits(T1 a1, T2 a2, T3 a3) {
bool IsFitIn32Bits(uint64_t a, uint64_t b, uint64_t c) { return IsFitIn32Bits(a1) && IsFitIn32Bits(a2) && IsFitIn32Bits(a3);
return IsFitIn32Bits(a) && IsFitIn32Bits(b) && IsFitIn32Bits(c);
} }
} // namespace } // namespace

View File

@ -10,6 +10,7 @@
#include <set> #include <set>
#include "packager/base/logging.h" #include "packager/base/logging.h"
#include "packager/base/macros.h"
#include "packager/base/stl_util.h" #include "packager/base/stl_util.h"
#include "packager/base/strings/string_number_conversions.h" #include "packager/base/strings/string_number_conversions.h"
#include "packager/mpd/base/media_info.pb.h" #include "packager/mpd/base/media_info.pb.h"