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

Side by Side Diff: media/mp4/box_reader_unittest.cc

Issue 10938034: Eliminate box reordering in media::mp4::BoxReader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/mp4/box_reader.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string.h> 5 #include <string.h>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "media/mp4/box_reader.h" 10 #include "media/mp4/box_reader.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 bool err; 138 bool err;
139 139
140 // Set an unrecognized top-level FourCC. 140 // Set an unrecognized top-level FourCC.
141 buf[5] = 1; 141 buf[5] = 1;
142 scoped_ptr<BoxReader> reader( 142 scoped_ptr<BoxReader> reader(
143 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &err)); 143 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &err));
144 EXPECT_FALSE(reader.get()); 144 EXPECT_FALSE(reader.get());
145 EXPECT_TRUE(err); 145 EXPECT_TRUE(err);
146 } 146 }
147 147
148 TEST_F(BoxReaderTest, ChildrenTest) { 148 TEST_F(BoxReaderTest, ScanChildrenTest) {
149 std::vector<uint8> buf = GetBuf(); 149 std::vector<uint8> buf = GetBuf();
150 bool err; 150 bool err;
151 scoped_ptr<BoxReader> reader( 151 scoped_ptr<BoxReader> reader(
152 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &err)); 152 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &err));
153 153
154 EXPECT_TRUE(reader->SkipBytes(16) && reader->ScanChildren()); 154 EXPECT_TRUE(reader->SkipBytes(16) && reader->ScanChildren());
155 155
156 FreeBox free; 156 FreeBox free;
157 EXPECT_TRUE(reader->ReadChild(&free)); 157 EXPECT_TRUE(reader->ReadChild(&free));
158 EXPECT_FALSE(reader->ReadChild(&free)); 158 EXPECT_FALSE(reader->ReadChild(&free));
159 EXPECT_TRUE(reader->MaybeReadChild(&free)); 159 EXPECT_TRUE(reader->MaybeReadChild(&free));
160 160
161 std::vector<PsshBox> kids; 161 std::vector<PsshBox> kids;
162 162
163 EXPECT_TRUE(reader->ReadAllChildren(&kids)); 163 EXPECT_TRUE(reader->ReadChildren(&kids));
164 EXPECT_EQ(2u, kids.size()); 164 EXPECT_EQ(2u, kids.size());
165 kids.clear(); 165 kids.clear();
166 EXPECT_FALSE(reader->ReadChildren(&kids)); 166 EXPECT_FALSE(reader->ReadChildren(&kids));
167 EXPECT_TRUE(reader->MaybeReadChildren(&kids)); 167 EXPECT_TRUE(reader->MaybeReadChildren(&kids));
168 } 168 }
169 169
170 TEST_F(BoxReaderTest, ReadAllChildrenTest) {
171 std::vector<uint8> buf = GetBuf();
172 // Modify buffer to exclude its last 'free' box
173 buf[3] = 0x38;
174 bool err;
175 scoped_ptr<BoxReader> reader(
176 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &err));
177
178 std::vector<PsshBox> kids;
179 EXPECT_TRUE(reader->SkipBytes(16) && reader->ReadAllChildren(&kids));
180 EXPECT_EQ(2u, kids.size());
181 EXPECT_EQ(kids[0].val, 0xdeadbeef); // Ensure order is preserved
182 }
183
170 } // namespace mp4 184 } // namespace mp4
171 } // namespace media 185 } // namespace media
OLDNEW
« no previous file with comments | « media/mp4/box_reader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698