Index: gpu/command_buffer/service/gpu_scheduler_unittest.cc |
=================================================================== |
--- gpu/command_buffer/service/gpu_scheduler_unittest.cc (revision 93137) |
+++ gpu/command_buffer/service/gpu_scheduler_unittest.cc (working copy) |
@@ -44,7 +44,7 @@ |
ON_CALL(*command_buffer_.get(), GetState()) |
.WillByDefault(Return(default_state)); |
- async_api_.reset(new StrictMock<AsyncAPIMock>); |
+ async_api_.reset(new StrictMock<SpecializedDoCommandAsyncAPIMock>); |
decoder_ = new gles2::MockGLES2Decoder(); |
@@ -55,9 +55,10 @@ |
0, |
async_api_.get()); |
- scheduler_.reset(gpu::GpuScheduler::CreateForTests(command_buffer_.get(), |
- decoder_, |
- parser_)); |
+ scheduler_.reset(new GpuScheduler(command_buffer_.get(), |
+ decoder_, |
+ parser_, |
+ 2)); |
EXPECT_CALL(*decoder_, Destroy()) |
.Times(1) |
@@ -96,7 +97,7 @@ |
EXPECT_CALL(*command_buffer_, SetParseError(_)) |
.Times(0); |
- scheduler_->PutChanged(); |
+ scheduler_->PutChanged(true); |
} |
TEST_F(GpuSchedulerTest, ProcessesOneCommand) { |
@@ -118,7 +119,7 @@ |
EXPECT_CALL(*command_buffer_, SetParseError(_)) |
.Times(0); |
- scheduler_->PutChanged(); |
+ scheduler_->PutChanged(true); |
} |
TEST_F(GpuSchedulerTest, ProcessesTwoCommands) { |
@@ -143,7 +144,7 @@ |
.WillOnce(Return(error::kNoError)); |
EXPECT_CALL(*command_buffer_, SetGetOffset(3)); |
- scheduler_->PutChanged(); |
+ scheduler_->PutChanged(true); |
} |
TEST_F(GpuSchedulerTest, SchedulerSetsTheGLContext) { |
@@ -156,9 +157,50 @@ |
EXPECT_CALL(*command_buffer_, GetState()) |
.WillRepeatedly(Return(state)); |
- scheduler_->PutChanged(); |
+ scheduler_->PutChanged(true); |
} |
+TEST_F(GpuSchedulerTest, PostsTaskToFinishRemainingCommands) { |
+ unsigned int pauseCmd = SpecializedDoCommandAsyncAPIMock::kTestQuantumCommand; |
+ CommandHeader* header = reinterpret_cast<CommandHeader*>(&buffer_[0]); |
+ header[0].command = 7; |
+ header[0].size = 2; |
+ buffer_[1] = 123; |
+ header[2].command = pauseCmd; |
+ header[2].size = 1; |
+ header[3].command = 9; |
+ header[3].size = 1; |
+ |
+ CommandBuffer::State state; |
+ |
+ state.put_offset = 4; |
+ EXPECT_CALL(*command_buffer_, GetState()) |
+ .WillRepeatedly(Return(state)); |
+ |
+ EXPECT_CALL(*async_api_, DoCommand(7, 1, &buffer_[0])) |
+ .WillOnce(Return(error::kNoError)); |
+ EXPECT_CALL(*command_buffer_, SetGetOffset(2)); |
+ |
+ EXPECT_CALL(*async_api_, DoCommand(pauseCmd, 0, &buffer_[2])) |
+ .WillOnce(Return(error::kNoError)); |
+ EXPECT_CALL(*command_buffer_, SetGetOffset(3)); |
+ |
+ scheduler_->PutChanged(true); |
+ |
+ // ProcessCommands is called a second time when the pending task is run. |
+ |
+ state.put_offset = 4; |
+ EXPECT_CALL(*command_buffer_, GetState()) |
+ .WillRepeatedly(Return(state)); |
+ |
+ EXPECT_CALL(*async_api_, DoCommand(9, 0, &buffer_[3])) |
+ .WillOnce(Return(error::kNoError)); |
+ |
+ EXPECT_CALL(*command_buffer_, SetGetOffset(4)); |
+ |
+ MessageLoop::current()->RunAllPending(); |
+} |
+ |
TEST_F(GpuSchedulerTest, SetsErrorCodeOnCommandBuffer) { |
CommandHeader* header = reinterpret_cast<CommandHeader*>(&buffer_[0]); |
header[0].command = 7; |
@@ -180,7 +222,7 @@ |
EXPECT_CALL(*command_buffer_, |
SetParseError(error::kUnknownCommand)); |
- scheduler_->PutChanged(); |
+ scheduler_->PutChanged(true); |
} |
TEST_F(GpuSchedulerTest, ProcessCommandsDoesNothingAfterError) { |
@@ -190,7 +232,7 @@ |
EXPECT_CALL(*command_buffer_, GetState()) |
.WillRepeatedly(Return(state)); |
- scheduler_->PutChanged(); |
+ scheduler_->PutChanged(true); |
} |
TEST_F(GpuSchedulerTest, CanGetAddressOfSharedMemory) { |