| 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()); |
| 38 } | 49 } |
| 39 | 50 |
| 40 #if !defined(OS_ANDROID) | 51 #if !defined(OS_ANDROID) |
| 41 TEST(DecoderBufferTest, PaddingAlignment) { | 52 TEST(DecoderBufferTest, PaddingAlignment) { |
| 42 const uint8 kData[] = "hello"; | 53 const uint8 kData[] = "hello"; |
| 43 const int kDataSize = arraysize(kData); | 54 const int kDataSize = arraysize(kData); |
| 44 scoped_refptr<DecoderBuffer> buffer2(DecoderBuffer::CopyFrom( | 55 scoped_refptr<DecoderBuffer> buffer2(DecoderBuffer::CopyFrom( |
| 45 reinterpret_cast<const uint8*>(&kData), kDataSize)); | 56 reinterpret_cast<const uint8*>(&kData), kDataSize)); |
| 46 ASSERT_TRUE(buffer2); | 57 ASSERT_TRUE(buffer2); |
| 47 | 58 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ASSERT_EQ(0, memcmp(read_only_data, kData, kDataSize)); | 91 ASSERT_EQ(0, memcmp(read_only_data, kData, kDataSize)); |
| 81 EXPECT_FALSE(buffer->IsEndOfStream()); | 92 EXPECT_FALSE(buffer->IsEndOfStream()); |
| 82 } | 93 } |
| 83 | 94 |
| 84 TEST(DecoderBufferTest, GetDecryptConfig) { | 95 TEST(DecoderBufferTest, GetDecryptConfig) { |
| 85 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(0)); | 96 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(0)); |
| 86 EXPECT_FALSE(buffer->GetDecryptConfig()); | 97 EXPECT_FALSE(buffer->GetDecryptConfig()); |
| 87 } | 98 } |
| 88 | 99 |
| 89 } // namespace media | 100 } // namespace media |
| OLD | NEW |