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

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

Issue 10441140: Make context groups share a TextureBufferManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 10 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
11 #include "gpu/command_buffer/service/mocks.h" 11 #include "gpu/command_buffer/service/mocks.h"
12 #include "gpu/command_buffer/service/command_buffer_service.h" 12 #include "gpu/command_buffer/service/command_buffer_service.h"
13 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
13 #include "gpu/command_buffer/service/gpu_scheduler.h" 14 #include "gpu/command_buffer/service/gpu_scheduler.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 #if defined(OS_MACOSX) 17 #if defined(OS_MACOSX)
17 #include "base/mac/scoped_nsautorelease_pool.h" 18 #include "base/mac/scoped_nsautorelease_pool.h"
18 #endif 19 #endif
19 20
20 namespace gpu { 21 namespace gpu {
21 22
22 using testing::Return; 23 using testing::Return;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 GpuScheduler* gpu_scheduler_; 59 GpuScheduler* gpu_scheduler_;
59 }; 60 };
60 61
61 virtual void SetUp() { 62 virtual void SetUp() {
62 api_mock_.reset(new AsyncAPIMock); 63 api_mock_.reset(new AsyncAPIMock);
63 // ignore noops in the mock - we don't want to inspect the internals of the 64 // ignore noops in the mock - we don't want to inspect the internals of the
64 // helper. 65 // helper.
65 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, _, _)) 66 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, _, _))
66 .WillRepeatedly(Return(error::kNoError)); 67 .WillRepeatedly(Return(error::kNoError));
67 68
68 command_buffer_.reset(new CommandBufferService); 69 {
apatrick_chromium 2012/05/31 23:57:33 Why is this in a block?
greggman 2012/06/01 00:01:45 just to make sure the variable "manager" isn't use
69 command_buffer_->Initialize(); 70 TransferBufferManager* manager = new TransferBufferManager();
71 transfer_buffer_manager_.reset(manager);
72 EXPECT_TRUE(manager->Initialize());
73 }
74 command_buffer_.reset(
75 new CommandBufferService(transfer_buffer_manager_.get()));
76 EXPECT_TRUE(command_buffer_->Initialize());
70 77
71 gpu_scheduler_.reset(new GpuScheduler( 78 gpu_scheduler_.reset(new GpuScheduler(
72 command_buffer_.get(), api_mock_.get(), NULL)); 79 command_buffer_.get(), api_mock_.get(), NULL));
73 command_buffer_->SetPutOffsetChangeCallback(base::Bind( 80 command_buffer_->SetPutOffsetChangeCallback(base::Bind(
74 &GpuScheduler::PutChanged, base::Unretained(gpu_scheduler_.get()))); 81 &GpuScheduler::PutChanged, base::Unretained(gpu_scheduler_.get())));
75 command_buffer_->SetGetBufferChangeCallback(base::Bind( 82 command_buffer_->SetGetBufferChangeCallback(base::Bind(
76 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get()))); 83 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get())));
77 84
78 do_jump_command_.reset(new DoJumpCommand(gpu_scheduler_.get())); 85 do_jump_command_.reset(new DoJumpCommand(gpu_scheduler_.get()));
79 EXPECT_CALL(*api_mock_, DoCommand(cmd::kJump, _, _)) 86 EXPECT_CALL(*api_mock_, DoCommand(cmd::kJump, _, _))
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return command_buffer_->GetState().error; 160 return command_buffer_->GetState().error;
154 } 161 }
155 162
156 CommandBufferOffset get_helper_put() { return helper_->put_; } 163 CommandBufferOffset get_helper_put() { return helper_->put_; }
157 164
158 #if defined(OS_MACOSX) 165 #if defined(OS_MACOSX)
159 base::mac::ScopedNSAutoreleasePool autorelease_pool_; 166 base::mac::ScopedNSAutoreleasePool autorelease_pool_;
160 #endif 167 #endif
161 MessageLoop message_loop_; 168 MessageLoop message_loop_;
162 scoped_ptr<AsyncAPIMock> api_mock_; 169 scoped_ptr<AsyncAPIMock> api_mock_;
170 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
163 scoped_ptr<CommandBufferService> command_buffer_; 171 scoped_ptr<CommandBufferService> command_buffer_;
164 scoped_ptr<GpuScheduler> gpu_scheduler_; 172 scoped_ptr<GpuScheduler> gpu_scheduler_;
165 scoped_ptr<CommandBufferHelper> helper_; 173 scoped_ptr<CommandBufferHelper> helper_;
166 Sequence sequence_; 174 Sequence sequence_;
167 scoped_ptr<DoJumpCommand> do_jump_command_; 175 scoped_ptr<DoJumpCommand> do_jump_command_;
168 }; 176 };
169 177
170 // Checks that commands in the buffer are properly executed, and that the 178 // Checks that commands in the buffer are properly executed, and that the
171 // status/error stay valid. 179 // status/error stay valid.
172 TEST_F(CommandBufferHelperTest, TestCommandProcessing) { 180 TEST_F(CommandBufferHelperTest, TestCommandProcessing) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 TEST_F(CommandBufferHelperTest, Noop) { 346 TEST_F(CommandBufferHelperTest, Noop) {
339 for (int ii = 1; ii < 4; ++ii) { 347 for (int ii = 1; ii < 4; ++ii) {
340 CommandBufferOffset put_before = get_helper_put(); 348 CommandBufferOffset put_before = get_helper_put();
341 helper_->Noop(ii); 349 helper_->Noop(ii);
342 CommandBufferOffset put_after = get_helper_put(); 350 CommandBufferOffset put_after = get_helper_put();
343 EXPECT_EQ(ii, put_after - put_before); 351 EXPECT_EQ(ii, put_after - put_before);
344 } 352 }
345 } 353 }
346 354
347 } // namespace gpu 355 } // namespace gpu
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.cc ('k') | gpu/command_buffer/client/fenced_allocator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698