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

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

Issue 9225001: Remove two static initializers (media/base/{buffers,media_log}.cc) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" 6 #include "base/memory/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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 291
292 292
293 TEST_F(SeekableBufferTest, GetTime) { 293 TEST_F(SeekableBufferTest, GetTime) {
294 const struct { 294 const struct {
295 int64 first_time_useconds; 295 int64 first_time_useconds;
296 int64 duration_useconds; 296 int64 duration_useconds;
297 size_t consume_bytes; 297 size_t consume_bytes;
298 int64 expected_time; 298 int64 expected_time;
299 } tests[] = { 299 } tests[] = {
300 // Timestamps of 0 are treated as garbage. 300 // Timestamps of 0 are treated as garbage.
301 { 0, 1000000, 0, kNoTimestamp.ToInternalValue() }, 301 { 0, 1000000, 0, kNoTimestamp().ToInternalValue() },
302 { 0, 4000000, 0, kNoTimestamp.ToInternalValue() }, 302 { 0, 4000000, 0, kNoTimestamp().ToInternalValue() },
303 { 0, 8000000, 0, kNoTimestamp.ToInternalValue() }, 303 { 0, 8000000, 0, kNoTimestamp().ToInternalValue() },
304 { 0, 1000000, 4, kNoTimestamp.ToInternalValue() }, 304 { 0, 1000000, 4, kNoTimestamp().ToInternalValue() },
305 { 0, 4000000, 4, kNoTimestamp.ToInternalValue() }, 305 { 0, 4000000, 4, kNoTimestamp().ToInternalValue() },
306 { 0, 8000000, 4, kNoTimestamp.ToInternalValue() }, 306 { 0, 8000000, 4, kNoTimestamp().ToInternalValue() },
307 { 0, 1000000, kWriteSize, kNoTimestamp.ToInternalValue() }, 307 { 0, 1000000, kWriteSize, kNoTimestamp().ToInternalValue() },
308 { 0, 4000000, kWriteSize, kNoTimestamp.ToInternalValue() }, 308 { 0, 4000000, kWriteSize, kNoTimestamp().ToInternalValue() },
309 { 0, 8000000, kWriteSize, kNoTimestamp.ToInternalValue() }, 309 { 0, 8000000, kWriteSize, kNoTimestamp().ToInternalValue() },
310 { 5, 1000000, 0, 5 }, 310 { 5, 1000000, 0, 5 },
311 { 5, 4000000, 0, 5 }, 311 { 5, 4000000, 0, 5 },
312 { 5, 8000000, 0, 5 }, 312 { 5, 8000000, 0, 5 },
313 { 5, 1000000, kWriteSize / 2, 500005 }, 313 { 5, 1000000, kWriteSize / 2, 500005 },
314 { 5, 4000000, kWriteSize / 2, 2000005 }, 314 { 5, 4000000, kWriteSize / 2, 2000005 },
315 { 5, 8000000, kWriteSize / 2, 4000005 }, 315 { 5, 8000000, kWriteSize / 2, 4000005 },
316 { 5, 1000000, kWriteSize, 1000005 }, 316 { 5, 1000000, kWriteSize, 1000005 },
317 { 5, 4000000, kWriteSize, 4000005 }, 317 { 5, 4000000, kWriteSize, 4000005 },
318 { 5, 8000000, kWriteSize, 8000005 }, 318 { 5, 8000000, kWriteSize, 8000005 },
319 }; 319 };
320 320
321 // current_time() must initially return kNoTimestamp. 321 // current_time() must initially return kNoTimestamp().
322 EXPECT_EQ(kNoTimestamp.ToInternalValue(), 322 EXPECT_EQ(kNoTimestamp().ToInternalValue(),
323 buffer_.current_time().ToInternalValue()); 323 buffer_.current_time().ToInternalValue());
324 324
325 scoped_refptr<media::DataBuffer> buffer(new media::DataBuffer(kWriteSize)); 325 scoped_refptr<media::DataBuffer> buffer(new media::DataBuffer(kWriteSize));
326 memcpy(buffer->GetWritableData(), data_, kWriteSize); 326 memcpy(buffer->GetWritableData(), data_, kWriteSize);
327 buffer->SetDataSize(kWriteSize); 327 buffer->SetDataSize(kWriteSize);
328 328
329 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 329 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
330 buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( 330 buffer->SetTimestamp(base::TimeDelta::FromMicroseconds(
331 tests[i].first_time_useconds)); 331 tests[i].first_time_useconds));
332 buffer->SetDuration(base::TimeDelta::FromMicroseconds( 332 buffer->SetDuration(base::TimeDelta::FromMicroseconds(
333 tests[i].duration_useconds)); 333 tests[i].duration_useconds));
334 buffer_.Append(buffer.get()); 334 buffer_.Append(buffer.get());
335 EXPECT_TRUE(buffer_.Seek(tests[i].consume_bytes)); 335 EXPECT_TRUE(buffer_.Seek(tests[i].consume_bytes));
336 336
337 int64 actual = buffer_.current_time().ToInternalValue(); 337 int64 actual = buffer_.current_time().ToInternalValue();
338 338
339 EXPECT_EQ(tests[i].expected_time, actual) << "With test = { start:" 339 EXPECT_EQ(tests[i].expected_time, actual) << "With test = { start:"
340 << tests[i].first_time_useconds << ", duration:" 340 << tests[i].first_time_useconds << ", duration:"
341 << tests[i].duration_useconds << ", consumed:" 341 << tests[i].duration_useconds << ", consumed:"
342 << tests[i].consume_bytes << "}\n"; 342 << tests[i].consume_bytes << "}\n";
343 343
344 buffer_.Clear(); 344 buffer_.Clear();
345 } 345 }
346 } 346 }
347 347
348 } // namespace media 348 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698