| 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 // This file contains the tests for the FencedAllocator class. | 5 // This file contains the tests for the FencedAllocator class. |
| 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 27 matching lines...) Expand all Loading... |
| 38 // ignore noops in the mock - we don't want to inspect the internals of the | 38 // ignore noops in the mock - we don't want to inspect the internals of the |
| 39 // helper. | 39 // helper. |
| 40 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _)) | 40 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _)) |
| 41 .WillRepeatedly(Return(error::kNoError)); | 41 .WillRepeatedly(Return(error::kNoError)); |
| 42 // Forward the SetToken calls to the engine | 42 // Forward the SetToken calls to the engine |
| 43 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) | 43 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) |
| 44 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), | 44 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), |
| 45 Return(error::kNoError))); | 45 Return(error::kNoError))); |
| 46 | 46 |
| 47 command_buffer_.reset(new CommandBufferService); | 47 command_buffer_.reset(new CommandBufferService); |
| 48 command_buffer_->Initialize(kBufferSize); | 48 command_buffer_->Initialize(); |
| 49 Buffer ring_buffer = command_buffer_->GetRingBuffer(); | |
| 50 | 49 |
| 51 parser_ = new CommandParser(ring_buffer.ptr, | 50 parser_ = new CommandParser(api_mock_.get()); |
| 52 ring_buffer.size, | |
| 53 0, | |
| 54 ring_buffer.size, | |
| 55 0, | |
| 56 api_mock_.get()); | |
| 57 | 51 |
| 58 gpu_scheduler_.reset(new GpuScheduler( | 52 gpu_scheduler_.reset(new GpuScheduler( |
| 59 command_buffer_.get(), NULL, parser_)); | 53 command_buffer_.get(), NULL, parser_)); |
| 60 command_buffer_->SetPutOffsetChangeCallback(base::Bind( | 54 command_buffer_->SetPutOffsetChangeCallback(base::Bind( |
| 61 &GpuScheduler::PutChanged, base::Unretained(gpu_scheduler_.get()))); | 55 &GpuScheduler::PutChanged, base::Unretained(gpu_scheduler_.get()))); |
| 62 | 56 |
| 63 api_mock_->set_engine(gpu_scheduler_.get()); | 57 api_mock_->set_engine(gpu_scheduler_.get()); |
| 64 | 58 |
| 65 helper_.reset(new CommandBufferHelper(command_buffer_.get())); | 59 helper_.reset(new CommandBufferHelper(command_buffer_.get())); |
| 66 helper_->Initialize(kBufferSize); | 60 helper_->Initialize(kBufferSize); |
| 61 |
| 62 // Note: parser->SetBuffer would normally be called through |
| 63 // helper_->Initialize but currently it needs a GpuCommandBufferStub as the |
| 64 // CommandBuffer instead of the CommandBufferService for that to happen. |
| 65 Buffer ring_buffer = helper_->get_ring_buffer(); |
| 66 parser_->SetBuffer(ring_buffer.ptr, ring_buffer.size, 0, ring_buffer.size); |
| 67 } | 67 } |
| 68 | 68 |
| 69 int32 GetToken() { | 69 int32 GetToken() { |
| 70 return command_buffer_->GetState().token; | 70 return command_buffer_->GetState().token; |
| 71 } | 71 } |
| 72 | 72 |
| 73 #if defined(OS_MACOSX) | 73 #if defined(OS_MACOSX) |
| 74 base::mac::ScopedNSAutoreleasePool autorelease_pool_; | 74 base::mac::ScopedNSAutoreleasePool autorelease_pool_; |
| 75 #endif | 75 #endif |
| 76 MessageLoop message_loop_; | 76 MessageLoop message_loop_; |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 EXPECT_LE(token, GetToken()); | 525 EXPECT_LE(token, GetToken()); |
| 526 | 526 |
| 527 // Free up everything. | 527 // Free up everything. |
| 528 for (unsigned int i = 0; i < kAllocCount; ++i) { | 528 for (unsigned int i = 0; i < kAllocCount; ++i) { |
| 529 allocator_->Free(pointers[i]); | 529 allocator_->Free(pointers[i]); |
| 530 EXPECT_TRUE(allocator_->CheckConsistency()); | 530 EXPECT_TRUE(allocator_->CheckConsistency()); |
| 531 } | 531 } |
| 532 } | 532 } |
| 533 | 533 |
| 534 } // namespace gpu | 534 } // namespace gpu |
| OLD | NEW |