| 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 GLES2Implementation. | 5 // Tests for GLES2Implementation. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/client_test_helper.h" | 7 #include "gpu/command_buffer/client/client_test_helper.h" |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 | 11 |
| 12 #include <memory> | 12 #include <memory> |
| 13 | 13 |
| 14 #include "gpu/command_buffer/client/cmd_buffer_helper.h" | 14 #include "gpu/command_buffer/client/cmd_buffer_helper.h" |
| 15 #include "gpu/command_buffer/common/command_buffer.h" | 15 #include "gpu/command_buffer/common/command_buffer.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 17 | 17 |
| 18 using ::testing::_; | 18 using ::testing::_; |
| 19 using ::testing::Invoke; | 19 using ::testing::Invoke; |
| 20 | 20 |
| 21 namespace gpu { | 21 namespace gpu { |
| 22 | 22 |
| 23 MockCommandBufferBase::MockCommandBufferBase() : put_offset_(0) { | 23 MockCommandBufferBase::MockCommandBufferBase() : put_offset_(0) {} |
| 24 } | |
| 25 | 24 |
| 26 MockCommandBufferBase::~MockCommandBufferBase() { | 25 MockCommandBufferBase::~MockCommandBufferBase() {} |
| 27 } | |
| 28 | 26 |
| 29 CommandBuffer::State MockCommandBufferBase::GetLastState() { | 27 CommandBuffer::State MockCommandBufferBase::GetLastState() { |
| 30 return state_; | 28 return state_; |
| 31 } | 29 } |
| 32 | 30 |
| 33 int32_t MockCommandBufferBase::GetLastToken() { | |
| 34 return state_.token; | |
| 35 } | |
| 36 | |
| 37 void MockCommandBufferBase::SetGetOffset(int32_t get_offset) { | 31 void MockCommandBufferBase::SetGetOffset(int32_t get_offset) { |
| 38 state_.get_offset = get_offset; | 32 state_.get_offset = get_offset; |
| 39 } | 33 } |
| 40 | 34 |
| 41 void MockCommandBufferBase::WaitForTokenInRange(int32_t start, int32_t end) {} | 35 void MockCommandBufferBase::SetReleaseCount(uint64_t release_count) { |
| 36 state_.release_count = release_count; |
| 37 } |
| 42 | 38 |
| 43 void MockCommandBufferBase::WaitForGetOffsetInRange(int32_t start, | 39 CommandBuffer::State MockCommandBufferBase::WaitForTokenInRange(int32_t start, |
| 44 int32_t end) { | 40 int32_t end) { |
| 41 return state_; |
| 42 } |
| 43 |
| 44 CommandBuffer::State MockCommandBufferBase::WaitForGetOffsetInRange( |
| 45 int32_t start, |
| 46 int32_t end) { |
| 45 state_.get_offset = put_offset_; | 47 state_.get_offset = put_offset_; |
| 46 OnFlush(); | 48 OnFlush(); |
| 49 return state_; |
| 47 } | 50 } |
| 48 | 51 |
| 49 void MockCommandBufferBase::SetGetBuffer(int transfer_buffer_id) { | 52 void MockCommandBufferBase::SetGetBuffer(int transfer_buffer_id) { |
| 50 ring_buffer_buffer_ = GetTransferBuffer(transfer_buffer_id); | 53 ring_buffer_buffer_ = GetTransferBuffer(transfer_buffer_id); |
| 51 ring_buffer_ = | 54 ring_buffer_ = |
| 52 static_cast<CommandBufferEntry*>(ring_buffer_buffer_->memory()); | 55 static_cast<CommandBufferEntry*>(ring_buffer_buffer_->memory()); |
| 53 state_.token = 10000; // All token checks in the tests should pass. | 56 state_.token = 10000; // All token checks in the tests should pass. |
| 54 } | 57 } |
| 55 | 58 |
| 56 // Get's the Id of the next transfer buffer that will be returned | 59 // Get's the Id of the next transfer buffer that will be returned |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // GCC requires these declarations, but MSVC requires they not be present | 121 // GCC requires these declarations, but MSVC requires they not be present |
| 119 #ifndef _MSC_VER | 122 #ifndef _MSC_VER |
| 120 const int32_t MockCommandBufferBase::kTransferBufferBaseId; | 123 const int32_t MockCommandBufferBase::kTransferBufferBaseId; |
| 121 const int32_t MockCommandBufferBase::kMaxTransferBuffers; | 124 const int32_t MockCommandBufferBase::kMaxTransferBuffers; |
| 122 #endif | 125 #endif |
| 123 | 126 |
| 124 MockClientCommandBuffer::MockClientCommandBuffer() { | 127 MockClientCommandBuffer::MockClientCommandBuffer() { |
| 125 DelegateToFake(); | 128 DelegateToFake(); |
| 126 } | 129 } |
| 127 | 130 |
| 128 MockClientCommandBuffer::~MockClientCommandBuffer() { | 131 MockClientCommandBuffer::~MockClientCommandBuffer() {} |
| 129 } | |
| 130 | 132 |
| 131 void MockClientCommandBuffer::Flush(int32_t put_offset) { | 133 void MockClientCommandBuffer::Flush(int32_t put_offset) { |
| 132 FlushHelper(put_offset); | 134 FlushHelper(put_offset); |
| 133 } | 135 } |
| 134 | 136 |
| 135 void MockClientCommandBuffer::OrderingBarrier(int32_t put_offset) { | 137 void MockClientCommandBuffer::OrderingBarrier(int32_t put_offset) { |
| 136 FlushHelper(put_offset); | 138 FlushHelper(put_offset); |
| 137 } | 139 } |
| 138 | 140 |
| 139 void MockClientCommandBuffer::DelegateToFake() { | 141 void MockClientCommandBuffer::DelegateToFake() { |
| 140 ON_CALL(*this, DestroyTransferBuffer(_)) | 142 ON_CALL(*this, DestroyTransferBuffer(_)) |
| 141 .WillByDefault(Invoke( | 143 .WillByDefault( |
| 142 this, &MockCommandBufferBase::DestroyTransferBufferHelper)); | 144 Invoke(this, &MockCommandBufferBase::DestroyTransferBufferHelper)); |
| 143 } | 145 } |
| 144 | 146 |
| 145 MockClientCommandBufferMockFlush::MockClientCommandBufferMockFlush() { | 147 MockClientCommandBufferMockFlush::MockClientCommandBufferMockFlush() { |
| 146 DelegateToFake(); | 148 DelegateToFake(); |
| 147 } | 149 } |
| 148 | 150 |
| 149 MockClientCommandBufferMockFlush::~MockClientCommandBufferMockFlush() { | 151 MockClientCommandBufferMockFlush::~MockClientCommandBufferMockFlush() {} |
| 150 } | |
| 151 | 152 |
| 152 void MockClientCommandBufferMockFlush::DelegateToFake() { | 153 void MockClientCommandBufferMockFlush::DelegateToFake() { |
| 153 MockClientCommandBuffer::DelegateToFake(); | 154 MockClientCommandBuffer::DelegateToFake(); |
| 154 ON_CALL(*this, Flush(_)) | 155 ON_CALL(*this, Flush(_)) |
| 155 .WillByDefault(Invoke( | 156 .WillByDefault(Invoke(this, &MockCommandBufferBase::FlushHelper)); |
| 156 this, &MockCommandBufferBase::FlushHelper)); | |
| 157 } | 157 } |
| 158 | 158 |
| 159 MockClientGpuControl::MockClientGpuControl() { | 159 MockClientGpuControl::MockClientGpuControl() {} |
| 160 } | |
| 161 | 160 |
| 162 MockClientGpuControl::~MockClientGpuControl() { | 161 MockClientGpuControl::~MockClientGpuControl() {} |
| 163 } | |
| 164 | 162 |
| 165 } // namespace gpu | 163 } // namespace gpu |
| 166 | |
| 167 | |
| OLD | NEW |