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

Unified Diff: media/webm/webm_parser_unittest.cc

Issue 9010001: Fix ChunkDemuxer seeks that occur during a partially parsed cluster. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: _ Created 9 years 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/webm/webm_parser_unittest.cc
diff --git a/media/webm/webm_parser_unittest.cc b/media/webm/webm_parser_unittest.cc
index e377fdac226002344fe10c2a9fbb90adea0c15f3..3c8600b98b9a79ee523c0c8ed7f58e35dcec6fcc 100644
--- a/media/webm/webm_parser_unittest.cc
+++ b/media/webm/webm_parser_unittest.cc
@@ -60,11 +60,13 @@ static Cluster* CreateCluster(int timecode,
static void CreateClusterExpectations(int timecode,
const SimpleBlockInfo* block_info,
int block_count,
+ bool is_complete_cluster,
MockWebMParserClient* client) {
InSequence s;
EXPECT_CALL(*client, OnListStart(kWebMIdCluster)).WillOnce(Return(true));
- EXPECT_CALL(*client, OnUInt(kWebMIdTimecode, 0)).WillOnce(Return(true));
+ EXPECT_CALL(*client, OnUInt(kWebMIdTimecode, timecode))
+ .WillOnce(Return(true));
for (int i = 0; i < block_count; i++) {
EXPECT_CALL(*client, OnSimpleBlock(block_info[i].track_num,
@@ -73,7 +75,8 @@ static void CreateClusterExpectations(int timecode,
.WillOnce(Return(true));
}
- EXPECT_CALL(*client, OnListEnd(kWebMIdCluster)).WillOnce(Return(true));
+ if (is_complete_cluster)
+ EXPECT_CALL(*client, OnListEnd(kWebMIdCluster)).WillOnce(Return(true));
}
TEST_F(WebMParserTest, EmptyCluster) {
@@ -211,7 +214,7 @@ TEST_F(WebMParserTest, ParseListElementWithSingleCall) {
int block_count = arraysize(kBlockInfo);
scoped_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
- CreateClusterExpectations(0, kBlockInfo, block_count, &client_);
+ CreateClusterExpectations(0, kBlockInfo, block_count, true, &client_);
WebMListParser parser(kWebMIdCluster);
int result = parser.Parse(cluster->data(), cluster->size(), &client_);
@@ -230,7 +233,7 @@ TEST_F(WebMParserTest, ParseListElementWithMultipleCalls) {
int block_count = arraysize(kBlockInfo);
scoped_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
- CreateClusterExpectations(0, kBlockInfo, block_count, &client_);
+ CreateClusterExpectations(0, kBlockInfo, block_count, true, &client_);
const uint8* data = cluster->data();
int size = cluster->size();
@@ -261,4 +264,41 @@ TEST_F(WebMParserTest, ParseListElementWithMultipleCalls) {
EXPECT_TRUE(parser.IsParsingComplete());
}
+TEST_F(WebMParserTest, TestReset) {
+ InSequence s;
+
+ const SimpleBlockInfo kBlockInfo[] = {
+ { 0, 1 },
+ { 1, 2 },
+ { 0, 3 },
+ { 0, 4 },
+ { 1, 4 },
+ };
+ int block_count = arraysize(kBlockInfo);
+
+ scoped_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
+
+ // First expect all but the last block.
+ CreateClusterExpectations(0, kBlockInfo, block_count - 1, false, &client_);
+
+ // Now expect all blocks.
+ CreateClusterExpectations(0, kBlockInfo, block_count, true, &client_);
+
+ WebMListParser parser(kWebMIdCluster);
+
+ // Send slightly less than the full cluster so all but the last block is
+ // parsed.
+ int result = parser.Parse(cluster->data(), cluster->size() - 1, &client_);
+ EXPECT_GT(result, 0);
+ EXPECT_LT(result, cluster->size());
+ EXPECT_FALSE(parser.IsParsingComplete());
+
+ parser.Reset();
+
+ // Now parse a whole cluster to verify that all the blocks will get parsed.
+ result = parser.Parse(cluster->data(), cluster->size(), &client_);
+ EXPECT_EQ(result, cluster->size());
+ EXPECT_TRUE(parser.IsParsingComplete());
+}
+
} // namespace media
« media/filters/chunk_demuxer_unittest.cc ('K') | « media/webm/webm_cluster_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698