Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: gpu/command_buffer/client/client_test_helper.cc

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "gpu/command_buffer/common/command_buffer.h" 9 #include "gpu/command_buffer/common/command_buffer.h"
10 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 10 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 12
13 using ::testing::_; 13 using ::testing::_;
14 using ::testing::Invoke; 14 using ::testing::Invoke;
15 15
16 namespace gpu { 16 namespace gpu {
17 17
18 MockCommandBufferBase::MockCommandBufferBase() { 18 MockCommandBufferBase::MockCommandBufferBase() : put_offset_(0) {
19 } 19 }
20 20
21 MockCommandBufferBase::~MockCommandBufferBase() { 21 MockCommandBufferBase::~MockCommandBufferBase() {
22 } 22 }
23 23
24 bool MockCommandBufferBase::Initialize() { 24 bool MockCommandBufferBase::Initialize() {
25 return true; 25 return true;
26 } 26 }
27 27
28 CommandBuffer::State MockCommandBufferBase::GetLastState() { 28 CommandBuffer::State MockCommandBufferBase::GetLastState() {
29 return state_; 29 return state_;
30 } 30 }
31 31
32 int32 MockCommandBufferBase::GetLastToken() { 32 int32 MockCommandBufferBase::GetLastToken() {
33 return state_.token; 33 return state_.token;
34 } 34 }
35 35
36 void MockCommandBufferBase::SetGetOffset(int32 get_offset) { 36 void MockCommandBufferBase::SetGetOffset(int32 get_offset) {
37 state_.get_offset = get_offset; 37 state_.get_offset = get_offset;
38 } 38 }
39 39
40 void MockCommandBufferBase::WaitForTokenInRange(int32 start, int32 end) {} 40 void MockCommandBufferBase::WaitForTokenInRange(int32 start, int32 end) {}
41 41
42 void MockCommandBufferBase::WaitForGetOffsetInRange(int32 start, int32 end) { 42 void MockCommandBufferBase::WaitForGetOffsetInRange(int32 start, int32 end) {
43 state_.get_offset = state_.put_offset; 43 state_.get_offset = put_offset_;
44 OnFlush(); 44 OnFlush();
45 } 45 }
46 46
47 void MockCommandBufferBase::SetGetBuffer(int transfer_buffer_id) { 47 void MockCommandBufferBase::SetGetBuffer(int transfer_buffer_id) {
48 ring_buffer_buffer_ = GetTransferBuffer(transfer_buffer_id); 48 ring_buffer_buffer_ = GetTransferBuffer(transfer_buffer_id);
49 ring_buffer_ = 49 ring_buffer_ =
50 static_cast<CommandBufferEntry*>(ring_buffer_buffer_->memory()); 50 static_cast<CommandBufferEntry*>(ring_buffer_buffer_->memory());
51 state_.num_entries = ring_buffer_buffer_->size() / sizeof(ring_buffer_[0]);
52 state_.token = 10000; // All token checks in the tests should pass. 51 state_.token = 10000; // All token checks in the tests should pass.
53 } 52 }
54 53
55 // Get's the Id of the next transfer buffer that will be returned 54 // Get's the Id of the next transfer buffer that will be returned
56 // by CreateTransferBuffer. This is useful for testing expected ids. 55 // by CreateTransferBuffer. This is useful for testing expected ids.
57 int32 MockCommandBufferBase::GetNextFreeTransferBufferId() { 56 int32 MockCommandBufferBase::GetNextFreeTransferBufferId() {
58 for (size_t ii = 0; ii < arraysize(transfer_buffer_buffers_); ++ii) { 57 for (size_t ii = 0; ii < arraysize(transfer_buffer_buffers_); ++ii) {
59 if (!transfer_buffer_buffers_[ii].get()) { 58 if (!transfer_buffer_buffers_[ii].get()) {
60 return kTransferBufferBaseId + ii; 59 return kTransferBufferBaseId + ii;
61 } 60 }
(...skipping 22 matching lines...) Expand all
84 transfer_buffer_buffers_[id] = NULL; 83 transfer_buffer_buffers_[id] = NULL;
85 } 84 }
86 85
87 scoped_refptr<Buffer> MockCommandBufferBase::GetTransferBuffer(int32 id) { 86 scoped_refptr<Buffer> MockCommandBufferBase::GetTransferBuffer(int32 id) {
88 DCHECK_GE(id, kTransferBufferBaseId); 87 DCHECK_GE(id, kTransferBufferBaseId);
89 DCHECK_LT(id, kTransferBufferBaseId + kMaxTransferBuffers); 88 DCHECK_LT(id, kTransferBufferBaseId + kMaxTransferBuffers);
90 return transfer_buffer_buffers_[id - kTransferBufferBaseId]; 89 return transfer_buffer_buffers_[id - kTransferBufferBaseId];
91 } 90 }
92 91
93 void MockCommandBufferBase::FlushHelper(int32 put_offset) { 92 void MockCommandBufferBase::FlushHelper(int32 put_offset) {
94 state_.put_offset = put_offset; 93 put_offset_ = put_offset;
95 } 94 }
96 95
97 void MockCommandBufferBase::SetToken(int32 token) { 96 void MockCommandBufferBase::SetToken(int32 token) {
98 NOTREACHED(); 97 NOTREACHED();
99 state_.token = token; 98 state_.token = token;
100 } 99 }
101 100
102 void MockCommandBufferBase::SetParseError(error::Error error) { 101 void MockCommandBufferBase::SetParseError(error::Error error) {
103 NOTREACHED(); 102 NOTREACHED();
104 state_.error = error; 103 state_.error = error;
105 } 104 }
106 105
107 void MockCommandBufferBase::SetContextLostReason( 106 void MockCommandBufferBase::SetContextLostReason(
108 error::ContextLostReason reason) { 107 error::ContextLostReason reason) {
109 NOTREACHED(); 108 NOTREACHED();
110 state_.context_lost_reason = reason; 109 state_.context_lost_reason = reason;
111 } 110 }
112 111
112 int32 MockCommandBufferBase::GetPutOffset() {
113 return put_offset_;
114 }
115
113 // GCC requires these declarations, but MSVC requires they not be present 116 // GCC requires these declarations, but MSVC requires they not be present
114 #ifndef _MSC_VER 117 #ifndef _MSC_VER
115 const int32 MockCommandBufferBase::kTransferBufferBaseId; 118 const int32 MockCommandBufferBase::kTransferBufferBaseId;
116 const int32 MockCommandBufferBase::kMaxTransferBuffers; 119 const int32 MockCommandBufferBase::kMaxTransferBuffers;
117 #endif 120 #endif
118 121
119 MockClientCommandBuffer::MockClientCommandBuffer() { 122 MockClientCommandBuffer::MockClientCommandBuffer() {
120 DelegateToFake(); 123 DelegateToFake();
121 } 124 }
122 125
(...skipping 26 matching lines...) Expand all
149 152
150 MockClientGpuControl::MockClientGpuControl() { 153 MockClientGpuControl::MockClientGpuControl() {
151 } 154 }
152 155
153 MockClientGpuControl::~MockClientGpuControl() { 156 MockClientGpuControl::~MockClientGpuControl() {
154 } 157 }
155 158
156 } // namespace gpu 159 } // namespace gpu
157 160
158 161
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/client_test_helper.h ('k') | gpu/command_buffer/client/cmd_buffer_helper_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698