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

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

Issue 1317063003: Reland of 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
« no previous file with comments | « media/formats/mp4/box_reader_unittest.cc ('k') | media/formats/mp4/track_run_iterator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6617312b1747322084209f45279a4ad285e204b9..620b81f0bcbe54d8bbd96a67dc43505c5d09d2dd 100644
--- a/media/formats/mp4/mp4_stream_parser_unittest.cc
+++ b/media/formats/mp4/mp4_stream_parser_unittest.cc
@@ -12,23 +12,41 @@
#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.
+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 +55,7 @@
}
protected:
+ scoped_refptr<StrictMock<MockMediaLog>> media_log_;
scoped_ptr<MP4StreamParser> parser_;
bool configs_received_;
AudioDecoderConfig audio_decoder_config_;
@@ -149,7 +168,7 @@
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 +191,30 @@
TEST_F(MP4StreamParserTest, UnalignedAppend) {
// Test small, non-segment-aligned appends (small enough to exercise
// incremental append system)
+ EXPECT_MEDIA_LOG(VideoCodecLog("avc1.6401f"));
+ EXPECT_MEDIA_LOG(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(VideoCodecLog("avc1.6401f"));
+ EXPECT_MEDIA_LOG(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(VideoCodecLog("avc1.6401f"));
+ EXPECT_MEDIA_LOG(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(VideoCodecLog("avc1.6401f")).Times(2);
+ EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")).Times(2);
InitializeParser();
scoped_refptr<DecoderBuffer> buffer =
@@ -200,6 +227,8 @@
}
TEST_F(MP4StreamParserTest, Reinitialization) {
+ EXPECT_MEDIA_LOG(VideoCodecLog("avc1.6401f")).Times(2);
+ EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")).Times(2);
InitializeParser();
scoped_refptr<DecoderBuffer> buffer =
@@ -213,14 +242,19 @@
}
TEST_F(MP4StreamParserTest, MPEG2_AAC_LC) {
+ InSequence s;
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(AudioCodecLog("mp4a.67"));
+ EXPECT_MEDIA_LOG(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(VideoCodecLog("avc1.6401f"));
+ EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2"));
InitializeParser();
scoped_refptr<DecoderBuffer> buffer =
@@ -240,18 +274,23 @@
// 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(AudioCodecLog("mp4a.40.2")).Times(2);
+ EXPECT_MEDIA_LOG(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(VideoCodecLog("avc1.4d4028"));
ParseMP4File("bear-1280x720-av_with-aud-nalus_frag.mp4", 512);
}
@@ -262,6 +301,7 @@
scoped_refptr<DecoderBuffer> buffer =
ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4");
+ EXPECT_MEDIA_LOG(VideoCodecLog("avc1.6401f"));
EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512));
}
@@ -271,6 +311,7 @@
scoped_refptr<DecoderBuffer> buffer =
ReadTestDataFile("bear-640x360-non_square_pixel-without_pasp.mp4");
+ EXPECT_MEDIA_LOG(VideoCodecLog("avc1.6401e"));
EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512));
EXPECT_EQ(gfx::Size(639, 360), video_decoder_config_.natural_size());
}
@@ -281,6 +322,7 @@
scoped_refptr<DecoderBuffer> buffer =
ReadTestDataFile("bear-640x360-non_square_pixel-with_pasp.mp4");
+ EXPECT_MEDIA_LOG(VideoCodecLog("avc1.6401e"));
EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512));
EXPECT_EQ(gfx::Size(639, 360), video_decoder_config_.natural_size());
}
« no previous file with comments | « media/formats/mp4/box_reader_unittest.cc ('k') | media/formats/mp4/track_run_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698