OLD | NEW |
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/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 0, | 70 0, |
71 ring_buffer.size, | 71 ring_buffer.size, |
72 0, | 72 0, |
73 api_mock_.get()); | 73 api_mock_.get()); |
74 | 74 |
75 do_jump_command_.reset(new DoJumpCommand(parser_)); | 75 do_jump_command_.reset(new DoJumpCommand(parser_)); |
76 EXPECT_CALL(*api_mock_, DoCommand(cmd::kJump, _, _)) | 76 EXPECT_CALL(*api_mock_, DoCommand(cmd::kJump, _, _)) |
77 .WillRepeatedly( | 77 .WillRepeatedly( |
78 Invoke(do_jump_command_.get(), &DoJumpCommand::DoCommand)); | 78 Invoke(do_jump_command_.get(), &DoJumpCommand::DoCommand)); |
79 | 79 |
80 gpu_scheduler_.reset(GpuScheduler::CreateForTests( | 80 gpu_scheduler_.reset(new GpuScheduler( |
81 command_buffer_.get(), NULL, parser_)); | 81 command_buffer_.get(), NULL, parser_, 1)); |
82 command_buffer_->SetPutOffsetChangeCallback(NewCallback( | 82 command_buffer_->SetPutOffsetChangeCallback(NewCallback( |
83 gpu_scheduler_.get(), &GpuScheduler::PutChanged)); | 83 gpu_scheduler_.get(), &GpuScheduler::PutChanged)); |
84 | 84 |
85 api_mock_->set_engine(gpu_scheduler_.get()); | 85 api_mock_->set_engine(gpu_scheduler_.get()); |
86 | 86 |
87 helper_.reset(new CommandBufferHelper(command_buffer_.get())); | 87 helper_.reset(new CommandBufferHelper(command_buffer_.get())); |
88 helper_->Initialize(kCommandBufferSizeBytes); | 88 helper_->Initialize(kCommandBufferSizeBytes); |
89 } | 89 } |
90 | 90 |
91 virtual void TearDown() { | 91 virtual void TearDown() { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 CommandBufferEntry args1[2]; | 178 CommandBufferEntry args1[2]; |
179 args1[0].value_uint32 = 3; | 179 args1[0].value_uint32 = 3; |
180 args1[1].value_float = 4.f; | 180 args1[1].value_float = 4.f; |
181 AddCommandWithExpect(error::kNoError, kUnusedCommandId, 2, args1); | 181 AddCommandWithExpect(error::kNoError, kUnusedCommandId, 2, args1); |
182 | 182 |
183 CommandBufferEntry args2[2]; | 183 CommandBufferEntry args2[2]; |
184 args2[0].value_uint32 = 5; | 184 args2[0].value_uint32 = 5; |
185 args2[1].value_float = 6.f; | 185 args2[1].value_float = 6.f; |
186 AddCommandWithExpect(error::kNoError, kUnusedCommandId, 2, args2); | 186 AddCommandWithExpect(error::kNoError, kUnusedCommandId, 2, args2); |
187 | 187 |
| 188 helper_->Flush(); |
| 189 // Check that the engine has work to do now. |
| 190 EXPECT_FALSE(parser_->IsEmpty()); |
| 191 |
188 // Wait until it's done. | 192 // Wait until it's done. |
189 helper_->Finish(); | 193 helper_->Finish(); |
190 // Check that the engine has no more work to do. | 194 // Check that the engine has no more work to do. |
191 EXPECT_TRUE(parser_->IsEmpty()); | 195 EXPECT_TRUE(parser_->IsEmpty()); |
192 | 196 |
193 // Check that the commands did happen. | 197 // Check that the commands did happen. |
194 Mock::VerifyAndClearExpectations(api_mock_.get()); | 198 Mock::VerifyAndClearExpectations(api_mock_.get()); |
195 | 199 |
196 // Check the error status. | 200 // Check the error status. |
197 EXPECT_EQ(error::kNoError, GetError()); | 201 EXPECT_EQ(error::kNoError, GetError()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 helper_->Finish(); | 301 helper_->Finish(); |
298 | 302 |
299 // Check that the commands did happen. | 303 // Check that the commands did happen. |
300 Mock::VerifyAndClearExpectations(api_mock_.get()); | 304 Mock::VerifyAndClearExpectations(api_mock_.get()); |
301 | 305 |
302 // Check the error status. | 306 // Check the error status. |
303 EXPECT_EQ(error::kNoError, GetError()); | 307 EXPECT_EQ(error::kNoError, GetError()); |
304 } | 308 } |
305 | 309 |
306 } // namespace gpu | 310 } // namespace gpu |
OLD | NEW |