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

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

Issue 13682: Checking in media::DataBuffer, a simple implementation of WritableBufferInterface. (Closed)
Patch Set: it try Created 12 years 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
« no previous file with comments | « media/base/data_buffer.cc ('k') | media/base/media.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/string_util.h"
6 #include "media/base/data_buffer.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 using media::DataBuffer;
10
11 TEST(DataBufferTest, Basic) {
12 const size_t kBufferSize = 32;
13 const char kData[] = "hello";
14 const size_t kDataSize = arraysize(kData);
15 const char kNewData[] = "chromium";
16 const size_t kNewDataSize = arraysize(kNewData);
17
18 // Create our buffer and copy some data into it.
19 char* data = new char[kBufferSize];
20 ASSERT_TRUE(data);
21 size_t copied = base::strlcpy(data, kData, kBufferSize);
22 EXPECT_EQ(kDataSize, copied + 1);
23
24 // Create a DataBuffer.
25 scoped_refptr<DataBuffer> buffer;
26 buffer = new DataBuffer(data, kBufferSize, kDataSize, 1337, 1667);
27 ASSERT_TRUE(buffer.get());
28
29 // Test StreamSampleInterface.
30 EXPECT_EQ(1337, buffer->GetTimestamp());
31 EXPECT_EQ(1667, buffer->GetDuration());
32 buffer->SetTimestamp(1234);
33 buffer->SetDuration(5678);
34 EXPECT_EQ(1234, buffer->GetTimestamp());
35 EXPECT_EQ(5678, buffer->GetDuration());
36
37 // Test BufferInterface.
38 ASSERT_EQ(data, buffer->GetData());
39 EXPECT_EQ(kDataSize, buffer->GetDataSize());
40 EXPECT_STREQ(kData, buffer->GetData());
41
42 // Test WritableBufferInterface.
43 ASSERT_EQ(data, buffer->GetWritableData());
44 EXPECT_EQ(kBufferSize, buffer->GetBufferSize());
45 copied = base::strlcpy(data, kNewData, kBufferSize);
46 EXPECT_EQ(kNewDataSize, copied + 1);
47 buffer->SetDataSize(kNewDataSize);
48 EXPECT_EQ(kNewDataSize, buffer->GetDataSize());
49 }
OLDNEW
« no previous file with comments | « media/base/data_buffer.cc ('k') | media/base/media.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698