| 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 // Tests for the BufferTracker. | 5 // Tests for the BufferTracker. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/buffer_tracker.h" | 7 #include "gpu/command_buffer/client/buffer_tracker.h" |
| 8 | 8 |
| 9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "gpu/command_buffer/client/client_test_helper.h" | 11 #include "gpu/command_buffer/client/client_test_helper.h" |
| 12 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 12 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 13 #include "gpu/command_buffer/client/mapped_memory.h" | 13 #include "gpu/command_buffer/client/mapped_memory.h" |
| 14 #include "gpu/command_buffer/common/command_buffer.h" | 14 #include "gpu/command_buffer/common/command_buffer.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace gpu { | 18 namespace gpu { |
| 19 namespace gles2 { | 19 namespace gles2 { |
| 20 | 20 |
| 21 class MockClientCommandBufferImpl : public MockClientCommandBuffer { | 21 class MockClientCommandBufferImpl : public MockClientCommandBuffer { |
| 22 public: | 22 public: |
| 23 MockClientCommandBufferImpl() | 23 MockClientCommandBufferImpl() |
| 24 : MockClientCommandBuffer(), | 24 : MockClientCommandBuffer(), |
| 25 context_lost_(false) {} | 25 context_lost_(false) {} |
| 26 virtual ~MockClientCommandBufferImpl() {} | 26 virtual ~MockClientCommandBufferImpl() {} |
| 27 | 27 |
| 28 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, | 28 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, |
| 29 int32* id) OVERRIDE { | 29 int32* id) override { |
| 30 if (context_lost_) { | 30 if (context_lost_) { |
| 31 *id = -1; | 31 *id = -1; |
| 32 return NULL; | 32 return NULL; |
| 33 } | 33 } |
| 34 return MockClientCommandBuffer::CreateTransferBuffer(size, id); | 34 return MockClientCommandBuffer::CreateTransferBuffer(size, id); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void set_context_lost(bool context_lost) { | 37 void set_context_lost(bool context_lost) { |
| 38 context_lost_ = context_lost; | 38 context_lost_ = context_lost; |
| 39 } | 39 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 buffer_tracker_->Unmanage(buffer); | 144 buffer_tracker_->Unmanage(buffer); |
| 145 buffer_tracker_->RemoveBuffer(kId); | 145 buffer_tracker_->RemoveBuffer(kId); |
| 146 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(size)); | 146 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(size)); |
| 147 | 147 |
| 148 mapped_memory_->Free(mem); | 148 mapped_memory_->Free(mem); |
| 149 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(0)); | 149 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(0)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace gles2 | 152 } // namespace gles2 |
| 153 } // namespace gpu | 153 } // namespace gpu |
| OLD | NEW |