OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/scoped_nsautorelease_pool.h" | 10 #include "base/scoped_nsautorelease_pool.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 command_buffer_->Initialize(kBufferSize / sizeof(CommandBufferEntry)); | 45 command_buffer_->Initialize(kBufferSize / sizeof(CommandBufferEntry)); |
46 Buffer ring_buffer = command_buffer_->GetRingBuffer(); | 46 Buffer ring_buffer = command_buffer_->GetRingBuffer(); |
47 | 47 |
48 parser_ = new CommandParser(ring_buffer.ptr, | 48 parser_ = new CommandParser(ring_buffer.ptr, |
49 ring_buffer.size, | 49 ring_buffer.size, |
50 0, | 50 0, |
51 ring_buffer.size, | 51 ring_buffer.size, |
52 0, | 52 0, |
53 api_mock_.get()); | 53 api_mock_.get()); |
54 | 54 |
55 scoped_refptr<GPUProcessor> gpu_processor(new GPUProcessor( | 55 gpu_processor_.reset(new GPUProcessor( |
56 command_buffer_.get(), NULL, parser_, INT_MAX)); | 56 command_buffer_.get(), NULL, parser_, INT_MAX)); |
57 command_buffer_->SetPutOffsetChangeCallback(NewCallback( | 57 command_buffer_->SetPutOffsetChangeCallback(NewCallback( |
58 gpu_processor.get(), &GPUProcessor::ProcessCommands)); | 58 gpu_processor_.get(), &GPUProcessor::ProcessCommands)); |
59 | 59 |
60 api_mock_->set_engine(gpu_processor.get()); | 60 api_mock_->set_engine(gpu_processor_.get()); |
61 | 61 |
62 helper_.reset(new CommandBufferHelper(command_buffer_.get())); | 62 helper_.reset(new CommandBufferHelper(command_buffer_.get())); |
63 helper_->Initialize(); | 63 helper_->Initialize(); |
64 } | 64 } |
65 | 65 |
66 int32 GetToken() { | 66 int32 GetToken() { |
67 return command_buffer_->GetState().token; | 67 return command_buffer_->GetState().token; |
68 } | 68 } |
69 | 69 |
70 virtual void TearDown() { | 70 virtual void TearDown() { |
71 helper_.release(); | 71 helper_.release(); |
72 } | 72 } |
73 | 73 |
74 base::ScopedNSAutoreleasePool autorelease_pool_; | 74 base::ScopedNSAutoreleasePool autorelease_pool_; |
75 base::AtExitManager at_exit_manager_; | 75 base::AtExitManager at_exit_manager_; |
76 MessageLoop message_loop_; | 76 MessageLoop message_loop_; |
77 scoped_ptr<AsyncAPIMock> api_mock_; | 77 scoped_ptr<AsyncAPIMock> api_mock_; |
78 scoped_ptr<CommandBufferService> command_buffer_; | 78 scoped_ptr<CommandBufferService> command_buffer_; |
| 79 scoped_ptr<GPUProcessor> gpu_processor_; |
79 CommandParser* parser_; | 80 CommandParser* parser_; |
80 scoped_ptr<CommandBufferHelper> helper_; | 81 scoped_ptr<CommandBufferHelper> helper_; |
81 }; | 82 }; |
82 | 83 |
83 #ifndef COMPILER_MSVC | 84 #ifndef COMPILER_MSVC |
84 const unsigned int BaseFencedAllocatorTest::kBufferSize; | 85 const unsigned int BaseFencedAllocatorTest::kBufferSize; |
85 #endif | 86 #endif |
86 | 87 |
87 // Test fixture for FencedAllocator test - Creates a FencedAllocator, using a | 88 // Test fixture for FencedAllocator test - Creates a FencedAllocator, using a |
88 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling | 89 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 EXPECT_LE(token, GetToken()); | 462 EXPECT_LE(token, GetToken()); |
462 | 463 |
463 // Free up everything. | 464 // Free up everything. |
464 for (unsigned int i = 0; i < kAllocCount; ++i) { | 465 for (unsigned int i = 0; i < kAllocCount; ++i) { |
465 allocator_->Free(pointers[i]); | 466 allocator_->Free(pointers[i]); |
466 EXPECT_TRUE(allocator_->CheckConsistency()); | 467 EXPECT_TRUE(allocator_->CheckConsistency()); |
467 } | 468 } |
468 } | 469 } |
469 | 470 |
470 } // namespace gpu | 471 } // namespace gpu |
OLD | NEW |