summaryrefslogtreecommitdiffstats
path: root/media/base/buffer_queue_unittest.cc
diff options
context:
space:
mode:
authorkylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 20:39:05 +0000
committerkylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 20:39:05 +0000
commit3cead8b0c7980c23171a569ee10b2b9835e4b941 (patch)
treea48ff765f755bc9cd00514bbcdcde4f63079f6c3 /media/base/buffer_queue_unittest.cc
parent2933580fcac85dbd0ad6eb5ccb5fe88fef40a128 (diff)
downloadchromium_src-3cead8b0c7980c23171a569ee10b2b9835e4b941.zip
chromium_src-3cead8b0c7980c23171a569ee10b2b9835e4b941.tar.gz
chromium_src-3cead8b0c7980c23171a569ee10b2b9835e4b941.tar.bz2
Add methods to ARAB and BufferQueue to allow owners to query it for the timestamp of our next byte.
BUG=16011 TEST=src/media/base/buffer_queue_unittest.cc Review URL: http://codereview.chromium.org/149494 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/buffer_queue_unittest.cc')
-rw-r--r--media/base/buffer_queue_unittest.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/media/base/buffer_queue_unittest.cc b/media/base/buffer_queue_unittest.cc
index 7f64b43..91e10e0 100644
--- a/media/base/buffer_queue_unittest.cc
+++ b/media/base/buffer_queue_unittest.cc
@@ -4,6 +4,7 @@
#include "base/scoped_ptr.h"
#include "base/string_util.h"
+#include "base/time.h"
#include "media/base/buffer_queue.h"
#include "media/base/data_buffer.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -123,4 +124,44 @@ TEST_F(BufferQueueTest, CopyFromMiddleOfBuffer) {
EXPECT_EQ(0, memcmp(dataBig, kData, kDataSize));
}
+TEST_F(BufferQueueTest, GetTime) {
+ const struct {
+ int64 first_time_seconds;
+ size_t consume_bytes;
+ double bytes_to_seconds;
+ } tests[] = {
+ { 0, 0, 0.5 },
+ { 0, 0, 1 },
+ { 0, 0, 1.75 },
+ { 0, 4, 0.5 },
+ { 0, 4, 1 },
+ { 0, 4, 1.75 },
+ { 5, 0, 0.5 },
+ { 5, 0, 1 },
+ { 5, 0, 1.75 },
+ { 5, 4, 0.5 },
+ { 5, 4, 1 },
+ { 5, 4, 1.75 },
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
+ buffer2->SetTimestamp(base::TimeDelta::FromSeconds(
+ tests[i].first_time_seconds));
+ queue_.Enqueue(buffer2.get());
+ queue_.Consume(tests[i].consume_bytes);
+
+ int64 expected = base::TimeDelta::FromSeconds(static_cast<int64>(
+ tests[i].first_time_seconds + (tests[i].consume_bytes *
+ tests[i].bytes_to_seconds))).ToInternalValue();
+
+ int64 actual = queue_.GetTime(tests[i].bytes_to_seconds).ToInternalValue();
+
+ EXPECT_EQ(expected, actual) << "With test = {"
+ << tests[i].first_time_seconds << ", " << tests[i].consume_bytes
+ << ", " << tests[i].bytes_to_seconds << "}\n";
+
+ queue_.Clear();
+ }
+}
+
} // namespace media