| 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 "gpu/command_buffer/service/transfer_buffer_manager.h" | 5 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 scoped_refptr<Buffer> registered = | 50 scoped_refptr<Buffer> registered = |
| 51 transfer_buffer_manager_->GetTransferBuffer(1); | 51 transfer_buffer_manager_->GetTransferBuffer(1); |
| 52 | 52 |
| 53 // Shared-memory ownership is transfered. It should be the same memory. | 53 // Shared-memory ownership is transfered. It should be the same memory. |
| 54 EXPECT_EQ(backing_raw_ptr, registered->backing()); | 54 EXPECT_EQ(backing_raw_ptr, registered->backing()); |
| 55 EXPECT_EQ(shm_raw_pointer, backing_raw_ptr->shared_memory()); | 55 EXPECT_EQ(shm_raw_pointer, backing_raw_ptr->shared_memory()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 class FakeBufferBacking : public BufferBacking { | 58 class FakeBufferBacking : public BufferBacking { |
| 59 public: | 59 public: |
| 60 virtual void* GetMemory() const OVERRIDE { | 60 virtual void* GetMemory() const override { |
| 61 return reinterpret_cast<void*>(0xBADF00D0); | 61 return reinterpret_cast<void*>(0xBADF00D0); |
| 62 } | 62 } |
| 63 virtual size_t GetSize() const OVERRIDE { return 42; } | 63 virtual size_t GetSize() const override { return 42; } |
| 64 static scoped_ptr<BufferBacking> Make() { | 64 static scoped_ptr<BufferBacking> Make() { |
| 65 return scoped_ptr<BufferBacking>(new FakeBufferBacking); | 65 return scoped_ptr<BufferBacking>(new FakeBufferBacking); |
| 66 } | 66 } |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 TEST_F(TransferBufferManagerTest, CanDestroyTransferBuffer) { | 69 TEST_F(TransferBufferManagerTest, CanDestroyTransferBuffer) { |
| 70 EXPECT_TRUE(transfer_buffer_manager_->RegisterTransferBuffer( | 70 EXPECT_TRUE(transfer_buffer_manager_->RegisterTransferBuffer( |
| 71 1, scoped_ptr<BufferBacking>(new FakeBufferBacking))); | 71 1, scoped_ptr<BufferBacking>(new FakeBufferBacking))); |
| 72 transfer_buffer_manager_->DestroyTransferBuffer(1); | 72 transfer_buffer_manager_->DestroyTransferBuffer(1); |
| 73 scoped_refptr<Buffer> registered = | 73 scoped_refptr<Buffer> registered = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 TEST_F(TransferBufferManagerTest, CannotRegisterNegativeTransferBufferId) { | 106 TEST_F(TransferBufferManagerTest, CannotRegisterNegativeTransferBufferId) { |
| 107 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 107 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
| 108 shm->CreateAndMapAnonymous(kBufferSize); | 108 shm->CreateAndMapAnonymous(kBufferSize); |
| 109 EXPECT_FALSE(transfer_buffer_manager_->RegisterTransferBuffer( | 109 EXPECT_FALSE(transfer_buffer_manager_->RegisterTransferBuffer( |
| 110 -1, FakeBufferBacking::Make())); | 110 -1, FakeBufferBacking::Make())); |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace gpu | 113 } // namespace gpu |
| OLD | NEW |