OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chromecast/media/cma/ipc/media_memory_chunk.h" | 8 #include "chromecast/media/cma/ipc/media_memory_chunk.h" |
9 #include "chromecast/media/cma/ipc/media_message.h" | 9 #include "chromecast/media/cma/ipc/media_message.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace chromecast { | 12 namespace chromecast { |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 class ExternalMemoryBlock | 17 class ExternalMemoryBlock |
18 : public MediaMemoryChunk { | 18 : public MediaMemoryChunk { |
19 public: | 19 public: |
20 ExternalMemoryBlock(void* data, size_t size) | 20 ExternalMemoryBlock(void* data, size_t size) |
21 : data_(data), size_(size) {} | 21 : data_(data), size_(size) {} |
22 virtual ~ExternalMemoryBlock() {} | 22 ~ExternalMemoryBlock() override {} |
23 | 23 |
24 // MediaMemoryChunk implementation. | 24 // MediaMemoryChunk implementation. |
25 virtual void* data() const override { return data_; } | 25 void* data() const override { return data_; } |
26 virtual size_t size() const override { return size_; } | 26 size_t size() const override { return size_; } |
27 virtual bool valid() const override { return true; } | 27 bool valid() const override { return true; } |
28 | 28 |
29 private: | 29 private: |
30 void* const data_; | 30 void* const data_; |
31 const size_t size_; | 31 const size_t size_; |
32 }; | 32 }; |
33 | 33 |
34 scoped_ptr<MediaMemoryChunk> DummyAllocator( | 34 scoped_ptr<MediaMemoryChunk> DummyAllocator( |
35 void* data, size_t size, size_t alloc_size) { | 35 void* data, size_t size, size_t alloc_size) { |
36 CHECK_LE(alloc_size, size); | 36 CHECK_LE(alloc_size, size); |
37 return scoped_ptr<MediaMemoryChunk>( | 37 return scoped_ptr<MediaMemoryChunk>( |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // Create the real message and write the actual content. | 137 // Create the real message and write the actual content. |
138 scoped_ptr<MediaMessage> msg2( | 138 scoped_ptr<MediaMessage> msg2( |
139 MediaMessage::CreateMessage(type, mem_alloc_cb, msg1->content_size())); | 139 MediaMessage::CreateMessage(type, mem_alloc_cb, msg1->content_size())); |
140 EXPECT_TRUE(msg2->WritePod(v1)); | 140 EXPECT_TRUE(msg2->WritePod(v1)); |
141 EXPECT_TRUE(msg2->WritePod(v1)); | 141 EXPECT_TRUE(msg2->WritePod(v1)); |
142 EXPECT_FALSE(msg2->WritePod(v1)); | 142 EXPECT_FALSE(msg2->WritePod(v1)); |
143 } | 143 } |
144 | 144 |
145 } // namespace media | 145 } // namespace media |
146 } // namespace chromecast | 146 } // namespace chromecast |
OLD | NEW |