OLD | NEW |
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 <cstdlib> | 5 #include <cstdlib> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "media/base/data_buffer.h" | 10 #include "media/base/data_buffer.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 { 5, 4000000, kWriteSize, 4000005 }, | 326 { 5, 4000000, kWriteSize, 4000005 }, |
327 { 5, 8000000, kWriteSize, 8000005 }, | 327 { 5, 8000000, kWriteSize, 8000005 }, |
328 }; | 328 }; |
329 | 329 |
330 // current_time() must initially return kNoTimestamp(). | 330 // current_time() must initially return kNoTimestamp(). |
331 EXPECT_EQ(kNoTimestamp().ToInternalValue(), | 331 EXPECT_EQ(kNoTimestamp().ToInternalValue(), |
332 buffer_.current_time().ToInternalValue()); | 332 buffer_.current_time().ToInternalValue()); |
333 | 333 |
334 scoped_refptr<DataBuffer> buffer = DataBuffer::CopyFrom(data_, kWriteSize); | 334 scoped_refptr<DataBuffer> buffer = DataBuffer::CopyFrom(data_, kWriteSize); |
335 | 335 |
336 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 336 for (size_t i = 0; i < arraysize(tests); ++i) { |
337 buffer->set_timestamp(base::TimeDelta::FromMicroseconds( | 337 buffer->set_timestamp(base::TimeDelta::FromMicroseconds( |
338 tests[i].first_time_useconds)); | 338 tests[i].first_time_useconds)); |
339 buffer->set_duration(base::TimeDelta::FromMicroseconds( | 339 buffer->set_duration(base::TimeDelta::FromMicroseconds( |
340 tests[i].duration_useconds)); | 340 tests[i].duration_useconds)); |
341 buffer_.Append(buffer.get()); | 341 buffer_.Append(buffer.get()); |
342 EXPECT_TRUE(buffer_.Seek(tests[i].consume_bytes)); | 342 EXPECT_TRUE(buffer_.Seek(tests[i].consume_bytes)); |
343 | 343 |
344 int64 actual = buffer_.current_time().ToInternalValue(); | 344 int64 actual = buffer_.current_time().ToInternalValue(); |
345 | 345 |
346 EXPECT_EQ(tests[i].expected_time, actual) << "With test = { start:" | 346 EXPECT_EQ(tests[i].expected_time, actual) << "With test = { start:" |
347 << tests[i].first_time_useconds << ", duration:" | 347 << tests[i].first_time_useconds << ", duration:" |
348 << tests[i].duration_useconds << ", consumed:" | 348 << tests[i].duration_useconds << ", consumed:" |
349 << tests[i].consume_bytes << " }\n"; | 349 << tests[i].consume_bytes << " }\n"; |
350 | 350 |
351 buffer_.Clear(); | 351 buffer_.Clear(); |
352 } | 352 } |
353 } | 353 } |
354 | 354 |
355 } // namespace media | 355 } // namespace media |
OLD | NEW |