Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1102)

Unified Diff: media/formats/mp4/mp4_stream_parser_unittest.cc

Issue 1300013002: MSE: Verify MediaLog events created by existing MP4 unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@more_mockmedialog_testing_webm
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/formats/mp4/mp4_stream_parser_unittest.cc
diff --git a/media/formats/mp4/mp4_stream_parser_unittest.cc b/media/formats/mp4/mp4_stream_parser_unittest.cc
index 0e631f47b763811057e2747fcd5718a21708846d..93e06960f2f0f0ff5b69ef6f2244b985f434179a 100644
--- a/media/formats/mp4/mp4_stream_parser_unittest.cc
+++ b/media/formats/mp4/mp4_stream_parser_unittest.cc
@@ -12,23 +12,43 @@
#include "base/time/time.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/decoder_buffer.h"
+#include "media/base/mock_media_log.h"
#include "media/base/stream_parser_buffer.h"
#include "media/base/test_data_util.h"
#include "media/base/text_track_config.h"
#include "media/base/video_decoder_config.h"
#include "media/formats/mp4/es_descriptor.h"
#include "media/formats/mp4/mp4_stream_parser.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using ::testing::InSequence;
+using ::testing::StrictMock;
using base::TimeDelta;
namespace media {
namespace mp4 {
+// Matchers for verifying common media log entry strings.
+#define CONTAINS_STRING(arg, x) (std::string::npos != (arg).find(x))
+
+MATCHER_P(VideoCodecLog, codec_string, "") {
+ return CONTAINS_STRING(arg, "Video codec: " + std::string(codec_string));
+}
+
+MATCHER_P(AudioCodecLog, codec_string, "") {
+ return CONTAINS_STRING(arg, "Audio codec: " + std::string(codec_string));
+}
+
+MATCHER(AuxInfoUnavailableLog, "") {
+ return CONTAINS_STRING(arg, "Aux Info is not available.");
+}
+
class MP4StreamParserTest : public testing::Test {
public:
MP4StreamParserTest()
- : configs_received_(false),
+ : media_log_(new StrictMock<MockMediaLog>()),
+ configs_received_(false),
lower_bound_(
DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max())) {
std::set<int> audio_object_types;
@@ -37,6 +57,7 @@ class MP4StreamParserTest : public testing::Test {
}
protected:
+ scoped_refptr<StrictMock<MockMediaLog>> media_log_;
scoped_ptr<MP4StreamParser> parser_;
bool configs_received_;
AudioDecoderConfig audio_decoder_config_;
@@ -149,7 +170,7 @@ class MP4StreamParserTest : public testing::Test {
base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)),
base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)),
base::Bind(&MP4StreamParserTest::EndOfSegmentF, base::Unretained(this)),
- new MediaLog());
+ media_log_);
}
void InitializeParser() {
@@ -172,22 +193,30 @@ class MP4StreamParserTest : public testing::Test {
TEST_F(MP4StreamParserTest, UnalignedAppend) {
// Test small, non-segment-aligned appends (small enough to exercise
// incremental append system)
+ EXPECT_MEDIA_LOG_STRING(VideoCodecLog("avc1.6401f"));
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2"));
ParseMP4File("bear-1280x720-av_frag.mp4", 512);
}
TEST_F(MP4StreamParserTest, BytewiseAppend) {
// Ensure no incremental errors occur when parsing
+ EXPECT_MEDIA_LOG_STRING(VideoCodecLog("avc1.6401f"));
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2"));
ParseMP4File("bear-1280x720-av_frag.mp4", 1);
}
TEST_F(MP4StreamParserTest, MultiFragmentAppend) {
// Large size ensures multiple fragments are appended in one call (size is
// larger than this particular test file)
+ EXPECT_MEDIA_LOG_STRING(VideoCodecLog("avc1.6401f"));
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2"));
ParseMP4File("bear-1280x720-av_frag.mp4", 768432);
}
TEST_F(MP4StreamParserTest, Flush) {
// Flush while reading sample data, then start a new stream.
+ EXPECT_MEDIA_LOG_STRING(VideoCodecLog("avc1.6401f")).Times(2);
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2")).Times(2);
InitializeParser();
scoped_refptr<DecoderBuffer> buffer =
@@ -200,6 +229,8 @@ TEST_F(MP4StreamParserTest, Flush) {
}
TEST_F(MP4StreamParserTest, Reinitialization) {
+ EXPECT_MEDIA_LOG_STRING(VideoCodecLog("avc1.6401f")).Times(2);
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2")).Times(2);
InitializeParser();
scoped_refptr<DecoderBuffer> buffer =
@@ -213,14 +244,19 @@ TEST_F(MP4StreamParserTest, Reinitialization) {
}
TEST_F(MP4StreamParserTest, MPEG2_AAC_LC) {
+ InSequence s;
chcunningham 2015/08/19 19:36:18 Do you need this? Ditto for line 279.
chcunningham 2015/08/19 20:06:43 ignore... I read up on InSequence. Kinda whacky, b
wolenetz 2015/08/24 20:13:52 Acknowledged.
std::set<int> audio_object_types;
audio_object_types.insert(kISO_13818_7_AAC_LC);
parser_.reset(new MP4StreamParser(audio_object_types, false));
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.67"));
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2"));
ParseMP4File("bear-mpeg2-aac-only_frag.mp4", 512);
}
// Test that a moov box is not always required after Flush() is called.
TEST_F(MP4StreamParserTest, NoMoovAfterFlush) {
+ EXPECT_MEDIA_LOG_STRING(VideoCodecLog("avc1.6401f"));
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2"));
InitializeParser();
scoped_refptr<DecoderBuffer> buffer =
@@ -240,18 +276,23 @@ TEST_F(MP4StreamParserTest, NoMoovAfterFlush) {
// SampleAuxiliaryInformation{Sizes|Offsets}Box (saiz|saio) are missing.
// The parser should fail instead of crash. See http://crbug.com/361347
TEST_F(MP4StreamParserTest, MissingSampleAuxInfo) {
+ InSequence s;
+
// Encrypted test mp4 files have non-zero duration and are treated as
// recorded streams.
InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED);
scoped_refptr<DecoderBuffer> buffer =
ReadTestDataFile("bear-1280x720-a_frag-cenc_missing-saiz-saio.mp4");
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2")).Times(2);
+ EXPECT_MEDIA_LOG_STRING(AuxInfoUnavailableLog());
EXPECT_FALSE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512));
}
// Test a file where all video samples start with an Access Unit
// Delimiter (AUD) NALU.
TEST_F(MP4StreamParserTest, VideoSamplesStartWithAUDs) {
+ EXPECT_MEDIA_LOG_STRING(VideoCodecLog("avc1.4d4028"));
ParseMP4File("bear-1280x720-av_with-aud-nalus_frag.mp4", 512);
}
@@ -262,6 +303,7 @@ TEST_F(MP4StreamParserTest, CENC) {
scoped_refptr<DecoderBuffer> buffer =
ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4");
+ EXPECT_MEDIA_LOG_STRING(VideoCodecLog("avc1.6401f"));
EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512));
}
@@ -271,6 +313,7 @@ TEST_F(MP4StreamParserTest, NaturalSizeWithoutPASP) {
scoped_refptr<DecoderBuffer> buffer =
ReadTestDataFile("bear-640x360-non_square_pixel-without_pasp.mp4");
+ EXPECT_MEDIA_LOG_STRING(VideoCodecLog("avc1.6401e"));
EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512));
EXPECT_EQ(gfx::Size(638, 360), video_decoder_config_.natural_size());
}
@@ -281,6 +324,7 @@ TEST_F(MP4StreamParserTest, NaturalSizeWithPASP) {
scoped_refptr<DecoderBuffer> buffer =
ReadTestDataFile("bear-640x360-non_square_pixel-with_pasp.mp4");
+ EXPECT_MEDIA_LOG_STRING(VideoCodecLog("avc1.6401e"));
EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512));
EXPECT_EQ(gfx::Size(638, 360), video_decoder_config_.natural_size());
}

Powered by Google App Engine
This is Rietveld 408576698