OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get()))); | 62 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get()))); |
63 | 63 |
64 api_mock_->set_engine(gpu_scheduler_.get()); | 64 api_mock_->set_engine(gpu_scheduler_.get()); |
65 | 65 |
66 helper_.reset(new CommandBufferHelper(command_buffer_.get())); | 66 helper_.reset(new CommandBufferHelper(command_buffer_.get())); |
67 helper_->Initialize(kCommandBufferSizeBytes); | 67 helper_->Initialize(kCommandBufferSizeBytes); |
68 } | 68 } |
69 | 69 |
70 virtual void TearDown() { | 70 virtual void TearDown() { |
71 // If the GpuScheduler posts any tasks, this forces them to run. | 71 // If the GpuScheduler posts any tasks, this forces them to run. |
72 MessageLoop::current()->RunUntilIdle(); | 72 base::MessageLoop::current()->RunUntilIdle(); |
73 } | 73 } |
74 | 74 |
75 const CommandParser* GetParser() const { | 75 const CommandParser* GetParser() const { |
76 return gpu_scheduler_->parser(); | 76 return gpu_scheduler_->parser(); |
77 } | 77 } |
78 | 78 |
79 // Adds a command to the buffer through the helper, while adding it as an | 79 // Adds a command to the buffer through the helper, while adding it as an |
80 // expected call on the API mock. | 80 // expected call on the API mock. |
81 void AddCommandWithExpect(error::Error _return, | 81 void AddCommandWithExpect(error::Error _return, |
82 unsigned int command, | 82 unsigned int command, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 error::Error GetError() { | 132 error::Error GetError() { |
133 return command_buffer_->GetState().error; | 133 return command_buffer_->GetState().error; |
134 } | 134 } |
135 | 135 |
136 CommandBufferOffset get_helper_put() { return helper_->put_; } | 136 CommandBufferOffset get_helper_put() { return helper_->put_; } |
137 | 137 |
138 #if defined(OS_MACOSX) | 138 #if defined(OS_MACOSX) |
139 base::mac::ScopedNSAutoreleasePool autorelease_pool_; | 139 base::mac::ScopedNSAutoreleasePool autorelease_pool_; |
140 #endif | 140 #endif |
141 MessageLoop message_loop_; | 141 base::MessageLoop message_loop_; |
142 scoped_ptr<AsyncAPIMock> api_mock_; | 142 scoped_ptr<AsyncAPIMock> api_mock_; |
143 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_; | 143 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_; |
144 scoped_ptr<CommandBufferService> command_buffer_; | 144 scoped_ptr<CommandBufferService> command_buffer_; |
145 scoped_ptr<GpuScheduler> gpu_scheduler_; | 145 scoped_ptr<GpuScheduler> gpu_scheduler_; |
146 scoped_ptr<CommandBufferHelper> helper_; | 146 scoped_ptr<CommandBufferHelper> helper_; |
147 Sequence sequence_; | 147 Sequence sequence_; |
148 }; | 148 }; |
149 | 149 |
150 // Checks that commands in the buffer are properly executed, and that the | 150 // Checks that commands in the buffer are properly executed, and that the |
151 // status/error stay valid. | 151 // status/error stay valid. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 } | 324 } |
325 } | 325 } |
326 | 326 |
327 TEST_F(CommandBufferHelperTest, IsContextLost) { | 327 TEST_F(CommandBufferHelperTest, IsContextLost) { |
328 EXPECT_FALSE(helper_->IsContextLost()); | 328 EXPECT_FALSE(helper_->IsContextLost()); |
329 command_buffer_->SetParseError(error::kGenericError); | 329 command_buffer_->SetParseError(error::kGenericError); |
330 EXPECT_TRUE(helper_->IsContextLost()); | 330 EXPECT_TRUE(helper_->IsContextLost()); |
331 } | 331 } |
332 | 332 |
333 } // namespace gpu | 333 } // namespace gpu |
OLD | NEW |