| 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/gl2.h> | 9 #include <GLES2/gl2.h> |
| 10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
| 11 #include <stddef.h> | 11 #include <stddef.h> |
| 12 #include <stdint.h> | 12 #include <stdint.h> |
| 13 #include "base/memory/scoped_ptr.h" | 13 |
| 14 #include <memory> |
| 15 |
| 14 #include "gpu/command_buffer/client/client_test_helper.h" | 16 #include "gpu/command_buffer/client/client_test_helper.h" |
| 15 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 17 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 16 #include "gpu/command_buffer/client/mapped_memory.h" | 18 #include "gpu/command_buffer/client/mapped_memory.h" |
| 17 #include "gpu/command_buffer/common/command_buffer.h" | 19 #include "gpu/command_buffer/common/command_buffer.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 22 |
| 21 namespace gpu { | 23 namespace gpu { |
| 22 namespace gles2 { | 24 namespace gles2 { |
| 23 | 25 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get())); | 62 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get())); |
| 61 } | 63 } |
| 62 | 64 |
| 63 void TearDown() override { | 65 void TearDown() override { |
| 64 buffer_tracker_.reset(); | 66 buffer_tracker_.reset(); |
| 65 mapped_memory_.reset(); | 67 mapped_memory_.reset(); |
| 66 helper_.reset(); | 68 helper_.reset(); |
| 67 command_buffer_.reset(); | 69 command_buffer_.reset(); |
| 68 } | 70 } |
| 69 | 71 |
| 70 scoped_ptr<MockClientCommandBufferImpl> command_buffer_; | 72 std::unique_ptr<MockClientCommandBufferImpl> command_buffer_; |
| 71 scoped_ptr<GLES2CmdHelper> helper_; | 73 std::unique_ptr<GLES2CmdHelper> helper_; |
| 72 scoped_ptr<MappedMemoryManager> mapped_memory_; | 74 std::unique_ptr<MappedMemoryManager> mapped_memory_; |
| 73 scoped_ptr<BufferTracker> buffer_tracker_; | 75 std::unique_ptr<BufferTracker> buffer_tracker_; |
| 74 }; | 76 }; |
| 75 | 77 |
| 76 TEST_F(BufferTrackerTest, Basic) { | 78 TEST_F(BufferTrackerTest, Basic) { |
| 77 const GLuint kId1 = 123; | 79 const GLuint kId1 = 123; |
| 78 const GLuint kId2 = 124; | 80 const GLuint kId2 = 124; |
| 79 const GLsizeiptr size = 64; | 81 const GLsizeiptr size = 64; |
| 80 | 82 |
| 81 // Check we can create a Buffer. | 83 // Check we can create a Buffer. |
| 82 BufferTracker::Buffer* buffer = buffer_tracker_->CreateBuffer(kId1, size); | 84 BufferTracker::Buffer* buffer = buffer_tracker_->CreateBuffer(kId1, size); |
| 83 ASSERT_TRUE(buffer != NULL); | 85 ASSERT_TRUE(buffer != NULL); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 buffer_tracker_->Unmanage(buffer); | 144 buffer_tracker_->Unmanage(buffer); |
| 143 buffer_tracker_->RemoveBuffer(kId); | 145 buffer_tracker_->RemoveBuffer(kId); |
| 144 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)); |
| 145 | 147 |
| 146 mapped_memory_->Free(mem); | 148 mapped_memory_->Free(mem); |
| 147 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)); |
| 148 } | 150 } |
| 149 | 151 |
| 150 } // namespace gles2 | 152 } // namespace gles2 |
| 151 } // namespace gpu | 153 } // namespace gpu |
| OLD | NEW |