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

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

Issue 8919014: Revert "Revert 113479 - Revert "Revert 113250 - Add CommandBuffer::SetGetBuffer"" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 }; 59 };
60 60
61 virtual void SetUp() { 61 virtual void SetUp() {
62 api_mock_.reset(new AsyncAPIMock); 62 api_mock_.reset(new AsyncAPIMock);
63 // ignore noops in the mock - we don't want to inspect the internals of the 63 // ignore noops in the mock - we don't want to inspect the internals of the
64 // helper. 64 // helper.
65 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, _, _)) 65 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, _, _))
66 .WillRepeatedly(Return(error::kNoError)); 66 .WillRepeatedly(Return(error::kNoError));
67 67
68 command_buffer_.reset(new CommandBufferService); 68 command_buffer_.reset(new CommandBufferService);
69 command_buffer_->Initialize(kCommandBufferSizeBytes); 69 command_buffer_->Initialize();
70 Buffer ring_buffer = command_buffer_->GetRingBuffer();
71 70
72 parser_ = new CommandParser(ring_buffer.ptr, 71 parser_ = new CommandParser(api_mock_.get());
73 ring_buffer.size,
74 0,
75 ring_buffer.size,
76 0,
77 api_mock_.get());
78 72
79 do_jump_command_.reset(new DoJumpCommand(parser_)); 73 do_jump_command_.reset(new DoJumpCommand(parser_));
80 EXPECT_CALL(*api_mock_, DoCommand(cmd::kJump, _, _)) 74 EXPECT_CALL(*api_mock_, DoCommand(cmd::kJump, _, _))
81 .WillRepeatedly( 75 .WillRepeatedly(
82 Invoke(do_jump_command_.get(), &DoJumpCommand::DoCommand)); 76 Invoke(do_jump_command_.get(), &DoJumpCommand::DoCommand));
83 77
84 gpu_scheduler_.reset(new GpuScheduler( 78 gpu_scheduler_.reset(new GpuScheduler(
85 command_buffer_.get(), NULL, parser_)); 79 command_buffer_.get(), NULL, parser_));
86 command_buffer_->SetPutOffsetChangeCallback(base::Bind( 80 command_buffer_->SetPutOffsetChangeCallback(base::Bind(
87 &GpuScheduler::PutChanged, base::Unretained(gpu_scheduler_.get()))); 81 &GpuScheduler::PutChanged, base::Unretained(gpu_scheduler_.get())));
88 82
89 api_mock_->set_engine(gpu_scheduler_.get()); 83 api_mock_->set_engine(gpu_scheduler_.get());
90 84
91 helper_.reset(new CommandBufferHelper(command_buffer_.get())); 85 helper_.reset(new CommandBufferHelper(command_buffer_.get()));
92 helper_->Initialize(kCommandBufferSizeBytes); 86 helper_->Initialize(kCommandBufferSizeBytes);
87
88 // Note: parser->SetBuffer would normally be called through
89 // helper_->Initialize but currently it needs a GpuCommandBufferStub as the
90 // CommandBuffer instead of the CommandBufferService for that to happen.
91 Buffer ring_buffer = helper_->get_ring_buffer();
92 parser_->SetBuffer(ring_buffer.ptr, ring_buffer.size, 0, ring_buffer.size);
93 } 93 }
94 94
95 virtual void TearDown() { 95 virtual void TearDown() {
96 // If the GpuScheduler posts any tasks, this forces them to run. 96 // If the GpuScheduler posts any tasks, this forces them to run.
97 MessageLoop::current()->RunAllPending(); 97 MessageLoop::current()->RunAllPending();
98 } 98 }
99 99
100 // Adds a command to the buffer through the helper, while adding it as an 100 // Adds a command to the buffer through the helper, while adding it as an
101 // expected call on the API mock. 101 // expected call on the API mock.
102 void AddCommandWithExpect(error::Error _return, 102 void AddCommandWithExpect(error::Error _return,
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 helper_->Finish(); 303 helper_->Finish();
304 304
305 // Check that the commands did happen. 305 // Check that the commands did happen.
306 Mock::VerifyAndClearExpectations(api_mock_.get()); 306 Mock::VerifyAndClearExpectations(api_mock_.get());
307 307
308 // Check the error status. 308 // Check the error status.
309 EXPECT_EQ(error::kNoError, GetError()); 309 EXPECT_EQ(error::kNoError, GetError());
310 } 310 }
311 311
312 } // namespace gpu 312 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper.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