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 // Tests for the Command Buffer Helper. | 5 // Tests for the Command Buffer Helper. |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 command_buffer_->Initialize(kNumCommandEntries); | 44 command_buffer_->Initialize(kNumCommandEntries); |
45 Buffer ring_buffer = command_buffer_->GetRingBuffer(); | 45 Buffer ring_buffer = command_buffer_->GetRingBuffer(); |
46 | 46 |
47 parser_ = new CommandParser(ring_buffer.ptr, | 47 parser_ = new CommandParser(ring_buffer.ptr, |
48 ring_buffer.size, | 48 ring_buffer.size, |
49 0, | 49 0, |
50 ring_buffer.size, | 50 ring_buffer.size, |
51 0, | 51 0, |
52 api_mock_.get()); | 52 api_mock_.get()); |
53 | 53 |
54 scoped_refptr<GPUProcessor> gpu_processor(new GPUProcessor( | 54 gpu_processor_.reset(new GPUProcessor( |
55 command_buffer_.get(), NULL, parser_, 1)); | 55 command_buffer_.get(), NULL, parser_, 1)); |
56 command_buffer_->SetPutOffsetChangeCallback(NewCallback( | 56 command_buffer_->SetPutOffsetChangeCallback(NewCallback( |
57 gpu_processor.get(), &GPUProcessor::ProcessCommands)); | 57 gpu_processor_.get(), &GPUProcessor::ProcessCommands)); |
58 | 58 |
59 api_mock_->set_engine(gpu_processor.get()); | 59 api_mock_->set_engine(gpu_processor_.get()); |
60 | 60 |
61 helper_.reset(new CommandBufferHelper(command_buffer_.get())); | 61 helper_.reset(new CommandBufferHelper(command_buffer_.get())); |
62 helper_->Initialize(); | 62 helper_->Initialize(); |
63 } | 63 } |
64 | 64 |
65 virtual void TearDown() { | 65 virtual void TearDown() { |
66 // If the GPUProcessor posts any tasks, this forces them to run. | 66 // If the GPUProcessor posts any tasks, this forces them to run. |
67 MessageLoop::current()->RunAllPending(); | 67 MessageLoop::current()->RunAllPending(); |
68 helper_.release(); | 68 helper_.release(); |
69 } | 69 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return command_buffer_->GetState().error; | 125 return command_buffer_->GetState().error; |
126 } | 126 } |
127 | 127 |
128 CommandBufferOffset get_helper_put() { return helper_->put_; } | 128 CommandBufferOffset get_helper_put() { return helper_->put_; } |
129 | 129 |
130 base::ScopedNSAutoreleasePool autorelease_pool_; | 130 base::ScopedNSAutoreleasePool autorelease_pool_; |
131 base::AtExitManager at_exit_manager_; | 131 base::AtExitManager at_exit_manager_; |
132 MessageLoop message_loop_; | 132 MessageLoop message_loop_; |
133 scoped_ptr<AsyncAPIMock> api_mock_; | 133 scoped_ptr<AsyncAPIMock> api_mock_; |
134 scoped_ptr<CommandBufferService> command_buffer_; | 134 scoped_ptr<CommandBufferService> command_buffer_; |
| 135 scoped_ptr<GPUProcessor> gpu_processor_; |
135 CommandParser* parser_; | 136 CommandParser* parser_; |
136 scoped_ptr<CommandBufferHelper> helper_; | 137 scoped_ptr<CommandBufferHelper> helper_; |
137 Sequence sequence_; | 138 Sequence sequence_; |
138 }; | 139 }; |
139 | 140 |
140 // Checks that commands in the buffer are properly executed, and that the | 141 // Checks that commands in the buffer are properly executed, and that the |
141 // status/error stay valid. | 142 // status/error stay valid. |
142 TEST_F(CommandBufferHelperTest, TestCommandProcessing) { | 143 TEST_F(CommandBufferHelperTest, TestCommandProcessing) { |
143 // Check initial state of the engine - it should have been configured by the | 144 // Check initial state of the engine - it should have been configured by the |
144 // helper. | 145 // helper. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 helper_->Finish(); | 275 helper_->Finish(); |
275 | 276 |
276 // Check that the commands did happen. | 277 // Check that the commands did happen. |
277 Mock::VerifyAndClearExpectations(api_mock_.get()); | 278 Mock::VerifyAndClearExpectations(api_mock_.get()); |
278 | 279 |
279 // Check the error status. | 280 // Check the error status. |
280 EXPECT_EQ(error::kNoError, GetError()); | 281 EXPECT_EQ(error::kNoError, GetError()); |
281 } | 282 } |
282 | 283 |
283 } // namespace gpu | 284 } // namespace gpu |
OLD | NEW |