summaryrefslogtreecommitdiffstats
path: root/media/base/data_buffer_unittest.cc
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-16 21:46:10 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-16 21:46:10 +0000
commitd8a447c5f7eef2dfe00a2a80466288be0d7329f7 (patch)
tree81378251205188e2718b4fc73282e62beca1c624 /media/base/data_buffer_unittest.cc
parentf7842f9049b7c2a16e29f01d713685ab32cd4c47 (diff)
downloadchromium_src-d8a447c5f7eef2dfe00a2a80466288be0d7329f7.zip
chromium_src-d8a447c5f7eef2dfe00a2a80466288be0d7329f7.tar.gz
chromium_src-d8a447c5f7eef2dfe00a2a80466288be0d7329f7.tar.bz2
Checking in media::DataBuffer, a simple implementation of WritableBufferInterface.
Removed media/base/media.cc, since it's no longer needed to generate media.lib. Also added media/using_media.scons and updated scons files for Linux build. Review URL: http://codereview.chromium.org/13682 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7099 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/data_buffer_unittest.cc')
-rw-r--r--media/base/data_buffer_unittest.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/media/base/data_buffer_unittest.cc b/media/base/data_buffer_unittest.cc
new file mode 100644
index 0000000..e9bb690
--- /dev/null
+++ b/media/base/data_buffer_unittest.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/string_util.h"
+#include "media/base/data_buffer.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using media::DataBuffer;
+
+TEST(DataBufferTest, Basic) {
+ const size_t kBufferSize = 32;
+ const char kData[] = "hello";
+ const size_t kDataSize = arraysize(kData);
+ const char kNewData[] = "chromium";
+ const size_t kNewDataSize = arraysize(kNewData);
+
+ // Create our buffer and copy some data into it.
+ char* data = new char[kBufferSize];
+ ASSERT_TRUE(data);
+ size_t copied = base::strlcpy(data, kData, kBufferSize);
+ EXPECT_EQ(kDataSize, copied + 1);
+
+ // Create a DataBuffer.
+ scoped_refptr<DataBuffer> buffer;
+ buffer = new DataBuffer(data, kBufferSize, kDataSize, 1337, 1667);
+ ASSERT_TRUE(buffer.get());
+
+ // Test StreamSampleInterface.
+ EXPECT_EQ(1337, buffer->GetTimestamp());
+ EXPECT_EQ(1667, buffer->GetDuration());
+ buffer->SetTimestamp(1234);
+ buffer->SetDuration(5678);
+ EXPECT_EQ(1234, buffer->GetTimestamp());
+ EXPECT_EQ(5678, buffer->GetDuration());
+
+ // Test BufferInterface.
+ ASSERT_EQ(data, buffer->GetData());
+ EXPECT_EQ(kDataSize, buffer->GetDataSize());
+ EXPECT_STREQ(kData, buffer->GetData());
+
+ // Test WritableBufferInterface.
+ ASSERT_EQ(data, buffer->GetWritableData());
+ EXPECT_EQ(kBufferSize, buffer->GetBufferSize());
+ copied = base::strlcpy(data, kNewData, kBufferSize);
+ EXPECT_EQ(kNewDataSize, copied + 1);
+ buffer->SetDataSize(kNewDataSize);
+ EXPECT_EQ(kNewDataSize, buffer->GetDataSize());
+}