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

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

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

Powered by Google App Engine
This is Rietveld 408576698