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

Side by Side Diff: media/base/seekable_buffer_unittest.cc

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 years, 1 month 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/base/pipeline_impl_unittest.cc ('k') | media/base/video_frame.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/scoped_ptr.h" 6 #include "base/scoped_ptr.h"
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "media/base/data_buffer.h" 8 #include "media/base/data_buffer.h"
9 #include "media/base/seekable_buffer.h" 9 #include "media/base/seekable_buffer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // Read again. 218 // Read again.
219 for (size_t i = 0; i < kBufferSize; i += kReadSize) { 219 for (size_t i = 0; i < kBufferSize; i += kReadSize) {
220 EXPECT_EQ(kReadSize, buffer_.Read(write_buffer_, kReadSize)); 220 EXPECT_EQ(kReadSize, buffer_.Read(write_buffer_, kReadSize));
221 EXPECT_EQ(0, memcmp(write_buffer_, data_ + i, kReadSize)); 221 EXPECT_EQ(0, memcmp(write_buffer_, data_ + i, kReadSize));
222 } 222 }
223 } 223 }
224 224
225 TEST_F(SeekableBufferTest, GetCurrentChunk) { 225 TEST_F(SeekableBufferTest, GetCurrentChunk) {
226 const size_t kSeekSize = kWriteSize / 3; 226 const size_t kSeekSize = kWriteSize / 3;
227 227
228 scoped_refptr<media::DataBuffer> buffer = new media::DataBuffer(kWriteSize); 228 scoped_refptr<media::DataBuffer> buffer(new media::DataBuffer(kWriteSize));
229 memcpy(buffer->GetWritableData(), data_, kWriteSize); 229 memcpy(buffer->GetWritableData(), data_, kWriteSize);
230 buffer->SetDataSize(kWriteSize); 230 buffer->SetDataSize(kWriteSize);
231 231
232 const uint8* data; 232 const uint8* data;
233 size_t size; 233 size_t size;
234 EXPECT_FALSE(buffer_.GetCurrentChunk(&data, &size)); 234 EXPECT_FALSE(buffer_.GetCurrentChunk(&data, &size));
235 235
236 buffer_.Append(buffer.get()); 236 buffer_.Append(buffer.get());
237 EXPECT_TRUE(buffer_.GetCurrentChunk(&data, &size)); 237 EXPECT_TRUE(buffer_.GetCurrentChunk(&data, &size));
238 EXPECT_EQ(data, buffer->GetData()); 238 EXPECT_EQ(data, buffer->GetData());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 { 5, 8000000, kWriteSize / 2, 4000005 }, 318 { 5, 8000000, kWriteSize / 2, 4000005 },
319 { 5, 1000000, kWriteSize, 1000005 }, 319 { 5, 1000000, kWriteSize, 1000005 },
320 { 5, 4000000, kWriteSize, 4000005 }, 320 { 5, 4000000, kWriteSize, 4000005 },
321 { 5, 8000000, kWriteSize, 8000005 }, 321 { 5, 8000000, kWriteSize, 8000005 },
322 }; 322 };
323 323
324 // current_time() must initially return kInvalidTimestamp. 324 // current_time() must initially return kInvalidTimestamp.
325 EXPECT_EQ(kInvalidTimestamp.ToInternalValue(), 325 EXPECT_EQ(kInvalidTimestamp.ToInternalValue(),
326 buffer_.current_time().ToInternalValue()); 326 buffer_.current_time().ToInternalValue());
327 327
328 scoped_refptr<media::DataBuffer> buffer = new media::DataBuffer(kWriteSize); 328 scoped_refptr<media::DataBuffer> buffer(new media::DataBuffer(kWriteSize));
329 memcpy(buffer->GetWritableData(), data_, kWriteSize); 329 memcpy(buffer->GetWritableData(), data_, kWriteSize);
330 buffer->SetDataSize(kWriteSize); 330 buffer->SetDataSize(kWriteSize);
331 331
332 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 332 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
333 buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( 333 buffer->SetTimestamp(base::TimeDelta::FromMicroseconds(
334 tests[i].first_time_useconds)); 334 tests[i].first_time_useconds));
335 buffer->SetDuration(base::TimeDelta::FromMicroseconds( 335 buffer->SetDuration(base::TimeDelta::FromMicroseconds(
336 tests[i].duration_useconds)); 336 tests[i].duration_useconds));
337 buffer_.Append(buffer.get()); 337 buffer_.Append(buffer.get());
338 EXPECT_TRUE(buffer_.Seek(tests[i].consume_bytes)); 338 EXPECT_TRUE(buffer_.Seek(tests[i].consume_bytes));
339 339
340 int64 actual = buffer_.current_time().ToInternalValue(); 340 int64 actual = buffer_.current_time().ToInternalValue();
341 341
342 EXPECT_EQ(tests[i].expected_time, actual) << "With test = { start:" 342 EXPECT_EQ(tests[i].expected_time, actual) << "With test = { start:"
343 << tests[i].first_time_useconds << ", duration:" 343 << tests[i].first_time_useconds << ", duration:"
344 << tests[i].duration_useconds << ", consumed:" 344 << tests[i].duration_useconds << ", consumed:"
345 << tests[i].consume_bytes << "}\n"; 345 << tests[i].consume_bytes << "}\n";
346 346
347 buffer_.Clear(); 347 buffer_.Clear();
348 } 348 }
349 } 349 }
350 350
351 } // namespace 351 } // namespace
OLDNEW
« no previous file with comments | « media/base/pipeline_impl_unittest.cc ('k') | media/base/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698