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 "base/string_util.h" | 5 #include "base/string_util.h" |
6 #include "media/base/decoder_buffer.h" | 6 #include "media/base/decoder_buffer.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace media { | 9 namespace media { |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 TEST(DecoderBufferTest, CopyFrom) { | 28 TEST(DecoderBufferTest, CopyFrom) { |
29 const uint8 kData[] = "hello"; | 29 const uint8 kData[] = "hello"; |
30 const int kDataSize = arraysize(kData); | 30 const int kDataSize = arraysize(kData); |
31 scoped_refptr<DecoderBuffer> buffer2(DecoderBuffer::CopyFrom( | 31 scoped_refptr<DecoderBuffer> buffer2(DecoderBuffer::CopyFrom( |
32 reinterpret_cast<const uint8*>(&kData), kDataSize)); | 32 reinterpret_cast<const uint8*>(&kData), kDataSize)); |
33 ASSERT_TRUE(buffer2); | 33 ASSERT_TRUE(buffer2); |
34 EXPECT_NE(kData, buffer2->GetData()); | 34 EXPECT_NE(kData, buffer2->GetData()); |
35 EXPECT_EQ(buffer2->GetDataSize(), kDataSize); | 35 EXPECT_EQ(buffer2->GetDataSize(), kDataSize); |
36 EXPECT_EQ(0, memcmp(buffer2->GetData(), kData, kDataSize)); | 36 EXPECT_EQ(0, memcmp(buffer2->GetData(), kData, kDataSize)); |
37 EXPECT_FALSE(buffer2->IsEndOfStream()); | 37 EXPECT_FALSE(buffer2->IsEndOfStream()); |
38 scoped_refptr<DecoderBuffer> buffer3(DecoderBuffer::CopyFrom( | |
39 reinterpret_cast<const uint8*>(&kData), kDataSize, | |
40 reinterpret_cast<const uint8*>(&kData), kDataSize)); | |
41 ASSERT_TRUE(buffer3); | |
42 EXPECT_NE(kData, buffer3->GetData()); | |
43 EXPECT_EQ(buffer3->GetDataSize(), kDataSize); | |
44 EXPECT_EQ(0, memcmp(buffer3->GetData(), kData, kDataSize)); | |
45 EXPECT_NE(kData, buffer3->GetSideData()); | |
46 EXPECT_EQ(buffer3->GetSideDataSize(), kDataSize); | |
47 EXPECT_EQ(0, memcmp(buffer3->GetSideData(), kData, kDataSize)); | |
48 EXPECT_FALSE(buffer3->IsEndOfStream()); | |
49 } | 38 } |
50 | 39 |
51 #if !defined(OS_ANDROID) | 40 #if !defined(OS_ANDROID) |
52 TEST(DecoderBufferTest, PaddingAlignment) { | 41 TEST(DecoderBufferTest, PaddingAlignment) { |
53 const uint8 kData[] = "hello"; | 42 const uint8 kData[] = "hello"; |
54 const int kDataSize = arraysize(kData); | 43 const int kDataSize = arraysize(kData); |
55 scoped_refptr<DecoderBuffer> buffer2(DecoderBuffer::CopyFrom( | 44 scoped_refptr<DecoderBuffer> buffer2(DecoderBuffer::CopyFrom( |
56 reinterpret_cast<const uint8*>(&kData), kDataSize)); | 45 reinterpret_cast<const uint8*>(&kData), kDataSize)); |
57 ASSERT_TRUE(buffer2); | 46 ASSERT_TRUE(buffer2); |
58 | 47 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 ASSERT_EQ(0, memcmp(read_only_data, kData, kDataSize)); | 80 ASSERT_EQ(0, memcmp(read_only_data, kData, kDataSize)); |
92 EXPECT_FALSE(buffer->IsEndOfStream()); | 81 EXPECT_FALSE(buffer->IsEndOfStream()); |
93 } | 82 } |
94 | 83 |
95 TEST(DecoderBufferTest, GetDecryptConfig) { | 84 TEST(DecoderBufferTest, GetDecryptConfig) { |
96 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(0)); | 85 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(0)); |
97 EXPECT_FALSE(buffer->GetDecryptConfig()); | 86 EXPECT_FALSE(buffer->GetDecryptConfig()); |
98 } | 87 } |
99 | 88 |
100 } // namespace media | 89 } // namespace media |
OLD | NEW |