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

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

Issue 113611: Handle end of stream for media... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008-2009 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/string_util.h" 5 #include "base/string_util.h"
6 #include "media/base/data_buffer.h" 6 #include "media/base/data_buffer.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 using media::DataBuffer; 9 using media::DataBuffer;
10 10
(...skipping 10 matching lines...) Expand all
21 // Create our buffer and copy some data into it. 21 // Create our buffer and copy some data into it.
22 // Create a DataBuffer. 22 // Create a DataBuffer.
23 scoped_refptr<DataBuffer> buffer = new DataBuffer(); 23 scoped_refptr<DataBuffer> buffer = new DataBuffer();
24 ASSERT_TRUE(buffer); 24 ASSERT_TRUE(buffer);
25 25
26 // Test StreamSample implementation. 26 // Test StreamSample implementation.
27 buffer->SetTimestamp(kTimestampA); 27 buffer->SetTimestamp(kTimestampA);
28 buffer->SetDuration(kDurationA); 28 buffer->SetDuration(kDurationA);
29 EXPECT_TRUE(kTimestampA == buffer->GetTimestamp()); 29 EXPECT_TRUE(kTimestampA == buffer->GetTimestamp());
30 EXPECT_TRUE(kDurationA == buffer->GetDuration()); 30 EXPECT_TRUE(kDurationA == buffer->GetDuration());
31 EXPECT_FALSE(buffer->IsEndOfStream()); 31 EXPECT_TRUE(buffer->IsEndOfStream());
32 EXPECT_FALSE(buffer->GetData());
32 EXPECT_FALSE(buffer->IsDiscontinuous()); 33 EXPECT_FALSE(buffer->IsDiscontinuous());
33 buffer->SetTimestamp(kTimestampB); 34 buffer->SetTimestamp(kTimestampB);
34 buffer->SetDuration(kDurationB); 35 buffer->SetDuration(kDurationB);
35 EXPECT_TRUE(kTimestampB == buffer->GetTimestamp()); 36 EXPECT_TRUE(kTimestampB == buffer->GetTimestamp());
36 EXPECT_TRUE(kDurationB == buffer->GetDuration()); 37 EXPECT_TRUE(kDurationB == buffer->GetDuration());
37 38
38 buffer->SetEndOfStream(true);
39 EXPECT_TRUE(buffer->IsEndOfStream());
40 buffer->SetEndOfStream(false);
41 EXPECT_FALSE(buffer->IsEndOfStream());
42 buffer->SetDiscontinuous(true); 39 buffer->SetDiscontinuous(true);
43 EXPECT_TRUE(buffer->IsDiscontinuous()); 40 EXPECT_TRUE(buffer->IsDiscontinuous());
44 buffer->SetDiscontinuous(false); 41 buffer->SetDiscontinuous(false);
45 EXPECT_FALSE(buffer->IsDiscontinuous()); 42 EXPECT_FALSE(buffer->IsDiscontinuous());
46 43
47 // Test WritableBuffer implementation. 44 // Test WritableBuffer implementation.
48 EXPECT_FALSE(buffer->GetData()); 45 EXPECT_FALSE(buffer->GetData());
49 uint8* data = buffer->GetWritableData(kDataSize); 46 uint8* data = buffer->GetWritableData(kDataSize);
50 ASSERT_TRUE(data); 47 ASSERT_TRUE(data);
51 ASSERT_EQ(buffer->GetDataSize(), kDataSize); 48 ASSERT_EQ(buffer->GetDataSize(), kDataSize);
52 memcpy(data, kData, kDataSize); 49 memcpy(data, kData, kDataSize);
53 const uint8* read_only_data = buffer->GetData(); 50 const uint8* read_only_data = buffer->GetData();
54 ASSERT_EQ(data, read_only_data); 51 ASSERT_EQ(data, read_only_data);
55 ASSERT_EQ(0, memcmp(read_only_data, kData, kDataSize)); 52 ASSERT_EQ(0, memcmp(read_only_data, kData, kDataSize));
53 EXPECT_FALSE(buffer->IsEndOfStream());
56 54
57 data = buffer->GetWritableData(kNewDataSize + 10); 55 data = buffer->GetWritableData(kNewDataSize + 10);
58 ASSERT_TRUE(data); 56 ASSERT_TRUE(data);
59 ASSERT_EQ(buffer->GetDataSize(), kNewDataSize + 10); 57 ASSERT_EQ(buffer->GetDataSize(), kNewDataSize + 10);
60 memcpy(data, kNewData, kNewDataSize); 58 memcpy(data, kNewData, kNewDataSize);
61 read_only_data = buffer->GetData(); 59 read_only_data = buffer->GetData();
62 buffer->SetDataSize(kNewDataSize); 60 buffer->SetDataSize(kNewDataSize);
63 EXPECT_EQ(buffer->GetDataSize(), kNewDataSize); 61 EXPECT_EQ(buffer->GetDataSize(), kNewDataSize);
64 ASSERT_EQ(data, read_only_data); 62 ASSERT_EQ(data, read_only_data);
65 EXPECT_EQ(0, memcmp(read_only_data, kNewData, kNewDataSize)); 63 EXPECT_EQ(0, memcmp(read_only_data, kNewData, kNewDataSize));
66 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698