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

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

Issue 2163093002: remove linked_ptr from gpu/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix? win32 compile Created 4 years, 5 months 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
« no previous file with comments | « no previous file | gpu/command_buffer/service/command_executor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 the Command Buffer Helper. 5 // Tests for the Command Buffer Helper.
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list>
11 #include <memory> 10 #include <memory>
11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/linked_ptr.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 18 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
19 #include "gpu/command_buffer/service/command_buffer_service.h" 19 #include "gpu/command_buffer/service/command_buffer_service.h"
20 #include "gpu/command_buffer/service/command_executor.h" 20 #include "gpu/command_buffer/service/command_executor.h"
21 #include "gpu/command_buffer/service/mocks.h" 21 #include "gpu/command_buffer/service/mocks.h"
22 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 22 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 namespace gpu { 25 namespace gpu {
26 26
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 .InSequence(sequence_) 157 .InSequence(sequence_)
158 .WillOnce(Return(_return)); 158 .WillOnce(Return(_return));
159 } 159 }
160 160
161 void AddUniqueCommandWithExpect(error::Error _return, int cmd_size) { 161 void AddUniqueCommandWithExpect(error::Error _return, int cmd_size) {
162 EXPECT_GE(cmd_size, 1); 162 EXPECT_GE(cmd_size, 1);
163 EXPECT_LT(cmd_size, kTotalNumCommandEntries); 163 EXPECT_LT(cmd_size, kTotalNumCommandEntries);
164 int arg_count = cmd_size - 1; 164 int arg_count = cmd_size - 1;
165 165
166 // Allocate array for args. 166 // Allocate array for args.
167 linked_ptr<std::vector<CommandBufferEntry> > args_ptr( 167 auto args_ptr =
168 new std::vector<CommandBufferEntry>(arg_count ? arg_count : 1)); 168 base::MakeUnique<CommandBufferEntry[]>(arg_count ? arg_count : 1);
169 169
170 for (int32_t ii = 0; ii < arg_count; ++ii) { 170 for (int32_t ii = 0; ii < arg_count; ++ii) {
171 (*args_ptr)[ii].value_uint32 = 0xF00DF00D + ii; 171 args_ptr[ii].value_uint32 = 0xF00DF00D + ii;
172 } 172 }
173 173
174 // Add command and save args in test_command_args_ until the test completes. 174 // Add command and save args in test_command_args_ until the test completes.
175 AddCommandWithExpect( 175 AddCommandWithExpect(
176 _return, test_command_next_id_++, arg_count, &(*args_ptr)[0]); 176 _return, test_command_next_id_++, arg_count, args_ptr.get());
177 test_command_args_.insert(test_command_args_.end(), args_ptr); 177 test_command_args_.push_back(std::move(args_ptr));
178 } 178 }
179 179
180 void TestCommandWrappingFull(int32_t cmd_size, int32_t start_commands) { 180 void TestCommandWrappingFull(int32_t cmd_size, int32_t start_commands) {
181 const int32_t num_args = cmd_size - 1; 181 const int32_t num_args = cmd_size - 1;
182 EXPECT_EQ(kTotalNumCommandEntries % cmd_size, 0); 182 EXPECT_EQ(kTotalNumCommandEntries % cmd_size, 0);
183 183
184 std::vector<CommandBufferEntry> args(num_args); 184 std::vector<CommandBufferEntry> args(num_args);
185 for (int32_t ii = 0; ii < num_args; ++ii) { 185 for (int32_t ii = 0; ii < num_args; ++ii) {
186 args[ii].value_uint32 = ii + 1; 186 args[ii].value_uint32 = ii + 1;
187 } 187 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return command_buffer_->GetLastState().error; 257 return command_buffer_->GetLastState().error;
258 } 258 }
259 259
260 CommandBufferOffset get_helper_put() { return helper_->put_; } 260 CommandBufferOffset get_helper_put() { return helper_->put_; }
261 261
262 std::unique_ptr<AsyncAPIMock> api_mock_; 262 std::unique_ptr<AsyncAPIMock> api_mock_;
263 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_; 263 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_;
264 std::unique_ptr<CommandBufferServiceLocked> command_buffer_; 264 std::unique_ptr<CommandBufferServiceLocked> command_buffer_;
265 std::unique_ptr<CommandExecutor> executor_; 265 std::unique_ptr<CommandExecutor> executor_;
266 std::unique_ptr<CommandBufferHelper> helper_; 266 std::unique_ptr<CommandBufferHelper> helper_;
267 std::list<linked_ptr<std::vector<CommandBufferEntry> > > test_command_args_; 267 std::vector<std::unique_ptr<CommandBufferEntry[]>> test_command_args_;
268 unsigned int test_command_next_id_; 268 unsigned int test_command_next_id_;
269 Sequence sequence_; 269 Sequence sequence_;
270 base::MessageLoop message_loop_; 270 base::MessageLoop message_loop_;
271 }; 271 };
272 272
273 // Checks immediate_entry_count_ changes based on 'usable' state. 273 // Checks immediate_entry_count_ changes based on 'usable' state.
274 TEST_F(CommandBufferHelperTest, TestCalcImmediateEntriesNotUsable) { 274 TEST_F(CommandBufferHelperTest, TestCalcImmediateEntriesNotUsable) {
275 // Auto flushing mode is tested separately. 275 // Auto flushing mode is tested separately.
276 helper_->SetAutomaticFlushes(false); 276 helper_->SetAutomaticFlushes(false);
277 EXPECT_EQ(helper_->usable(), true); 277 EXPECT_EQ(helper_->usable(), true);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 helper_->OrderingBarrier(); 763 helper_->OrderingBarrier();
764 flush_count2 = command_buffer_->FlushCount(); 764 flush_count2 = command_buffer_->FlushCount();
765 helper_->OrderingBarrier(); 765 helper_->OrderingBarrier();
766 flush_count3 = command_buffer_->FlushCount(); 766 flush_count3 = command_buffer_->FlushCount();
767 767
768 EXPECT_EQ(flush_count2, flush_count1 + 1); 768 EXPECT_EQ(flush_count2, flush_count1 + 1);
769 EXPECT_EQ(flush_count3, flush_count2 + 1); 769 EXPECT_EQ(flush_count3, flush_count2 + 1);
770 } 770 }
771 771
772 } // namespace gpu 772 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/command_executor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698