| 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 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/scoped_nsautorelease_pool.h" | 6 #include "base/scoped_nsautorelease_pool.h" |
| 7 #include "gpu/command_buffer/common/command_buffer_mock.h" | 7 #include "gpu/command_buffer/common/command_buffer_mock.h" |
| 8 #include "gpu/command_buffer/service/context_group.h" | 8 #include "gpu/command_buffer/service/context_group.h" |
| 9 #include "gpu/command_buffer/service/gpu_processor.h" | 9 #include "gpu/command_buffer/service/gpu_processor.h" |
| 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 kRingBufferEntries, | 54 kRingBufferEntries, |
| 55 0, | 55 0, |
| 56 kRingBufferEntries, | 56 kRingBufferEntries, |
| 57 0, | 57 0, |
| 58 async_api_.get()); | 58 async_api_.get()); |
| 59 | 59 |
| 60 processor_.reset(new GPUProcessor(command_buffer_.get(), | 60 processor_.reset(new GPUProcessor(command_buffer_.get(), |
| 61 decoder_, | 61 decoder_, |
| 62 parser_, | 62 parser_, |
| 63 2)); | 63 2)); |
| 64 |
| 65 EXPECT_CALL(*decoder_, Destroy()) |
| 66 .Times(1) |
| 67 .RetiresOnSaturation(); |
| 64 } | 68 } |
| 65 | 69 |
| 66 virtual void TearDown() { | 70 virtual void TearDown() { |
| 67 // Ensure that any unexpected tasks posted by the GPU processor are executed | 71 // Ensure that any unexpected tasks posted by the GPU processor are executed |
| 68 // in order to fail the test. | 72 // in order to fail the test. |
| 69 MessageLoop::current()->RunAllPending(); | 73 MessageLoop::current()->RunAllPending(); |
| 70 } | 74 } |
| 71 | 75 |
| 72 error::Error GetError() { | 76 error::Error GetError() { |
| 73 return command_buffer_->GetState().error; | 77 return command_buffer_->GetState().error; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 .WillOnce(Return(error::kNoError)); | 145 .WillOnce(Return(error::kNoError)); |
| 142 | 146 |
| 143 EXPECT_CALL(*async_api_, DoCommand(8, 0, &buffer_[2])) | 147 EXPECT_CALL(*async_api_, DoCommand(8, 0, &buffer_[2])) |
| 144 .WillOnce(Return(error::kNoError)); | 148 .WillOnce(Return(error::kNoError)); |
| 145 | 149 |
| 146 processor_->ProcessCommands(); | 150 processor_->ProcessCommands(); |
| 147 } | 151 } |
| 148 | 152 |
| 149 TEST_F(GPUProcessorTest, ProcessorSetsTheGLContext) { | 153 TEST_F(GPUProcessorTest, ProcessorSetsTheGLContext) { |
| 150 EXPECT_CALL(*decoder_, MakeCurrent()) | 154 EXPECT_CALL(*decoder_, MakeCurrent()) |
| 155 .WillOnce(Return(true)) |
| 151 .WillOnce(Return(true)); | 156 .WillOnce(Return(true)); |
| 152 | 157 |
| 153 CommandBuffer::State state; | 158 CommandBuffer::State state; |
| 154 state.put_offset = 0; | 159 state.put_offset = 0; |
| 155 EXPECT_CALL(*command_buffer_, GetState()) | 160 EXPECT_CALL(*command_buffer_, GetState()) |
| 156 .WillOnce(Return(state)); | 161 .WillOnce(Return(state)); |
| 157 | 162 |
| 158 EXPECT_CALL(*command_buffer_, SetGetOffset(0)); | 163 EXPECT_CALL(*command_buffer_, SetGetOffset(0)); |
| 159 | 164 |
| 160 processor_->ProcessCommands(); | 165 processor_->ProcessCommands(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 253 |
| 249 EXPECT_EQ(kRingBufferSize, processor_->GetSharedMemoryBuffer(7).size); | 254 EXPECT_EQ(kRingBufferSize, processor_->GetSharedMemoryBuffer(7).size); |
| 250 } | 255 } |
| 251 | 256 |
| 252 TEST_F(GPUProcessorTest, SetTokenForwardsToCommandBuffer) { | 257 TEST_F(GPUProcessorTest, SetTokenForwardsToCommandBuffer) { |
| 253 EXPECT_CALL(*command_buffer_, SetToken(7)); | 258 EXPECT_CALL(*command_buffer_, SetToken(7)); |
| 254 processor_->set_token(7); | 259 processor_->set_token(7); |
| 255 } | 260 } |
| 256 | 261 |
| 257 } // namespace gpu | 262 } // namespace gpu |
| OLD | NEW |