diff options
author | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-20 22:56:24 +0000 |
---|---|---|
committer | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-20 22:56:24 +0000 |
commit | 2399c759b3119d5657370c950f6eba3808cec44f (patch) | |
tree | dfba1eb5e8de279a892fb4f75d39e604032757e7 | |
parent | ebc5c8be10f0b82b428064c50be6e6a42861b9e1 (diff) | |
download | chromium_src-2399c759b3119d5657370c950f6eba3808cec44f.zip chromium_src-2399c759b3119d5657370c950f6eba3808cec44f.tar.gz chromium_src-2399c759b3119d5657370c950f6eba3808cec44f.tar.bz2 |
Fix ringbuffer test.
The SetToken mock was using the command header as the token value. Also, the ringbuffer test didn't support the jump command, so if the number of entries in the command buffer is too small then the test breaks.
BUG=
TEST=
Review URL: http://codereview.chromium.org/6990002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86167 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | gpu/command_buffer/client/ring_buffer_test.cc | 25 | ||||
-rw-r--r-- | gpu/command_buffer/service/mocks.cc | 6 |
2 files changed, 28 insertions, 3 deletions
diff --git a/gpu/command_buffer/client/ring_buffer_test.cc b/gpu/command_buffer/client/ring_buffer_test.cc index 1ccd979..01bc3e0 100644 --- a/gpu/command_buffer/client/ring_buffer_test.cc +++ b/gpu/command_buffer/client/ring_buffer_test.cc @@ -30,6 +30,25 @@ class BaseRingBufferTest : public testing::Test { static const unsigned int kBaseOffset = 128; static const unsigned int kBufferSize = 1024; + class DoJumpCommand { + public: + explicit DoJumpCommand(CommandParser* parser) + : parser_(parser) { + } + + error::Error DoCommand( + unsigned int command, + unsigned int arg_count, + const void* cmd_data) { + const cmd::Jump* jump_cmd = static_cast<const cmd::Jump*>(cmd_data); + parser_->set_get(jump_cmd->offset); + return error::kNoError; + }; + + private: + CommandParser* parser_; + }; + virtual void SetUp() { api_mock_.reset(new AsyncAPIMock); // ignore noops in the mock - we don't want to inspect the internals of the @@ -58,6 +77,10 @@ class BaseRingBufferTest : public testing::Test { gpu_scheduler_.get(), &GpuScheduler::PutChanged)); api_mock_->set_engine(gpu_scheduler_.get()); + do_jump_command_.reset(new DoJumpCommand(parser_)); + EXPECT_CALL(*api_mock_, DoCommand(cmd::kJump, _, _)) + .WillRepeatedly( + Invoke(do_jump_command_.get(), &DoJumpCommand::DoCommand)); helper_.reset(new CommandBufferHelper(command_buffer_.get())); helper_->Initialize(kBufferSize); @@ -74,6 +97,7 @@ class BaseRingBufferTest : public testing::Test { scoped_ptr<GpuScheduler> gpu_scheduler_; CommandParser* parser_; scoped_ptr<CommandBufferHelper> helper_; + scoped_ptr<DoJumpCommand> do_jump_command_; }; #ifndef _MSC_VER @@ -256,6 +280,7 @@ TEST_F(RingBufferWrapperTest, TestFreePendingToken) { EXPECT_LE(tokens[0], GetToken()); allocator_->FreePendingToken(pointer1, helper_->InsertToken()); + EXPECT_LE(command_buffer_->GetState().token, helper_->InsertToken()); } } // namespace gpu diff --git a/gpu/command_buffer/service/mocks.cc b/gpu/command_buffer/service/mocks.cc index 6f267be..40b3d6d9 100644 --- a/gpu/command_buffer/service/mocks.cc +++ b/gpu/command_buffer/service/mocks.cc @@ -19,9 +19,9 @@ void AsyncAPIMock::SetToken(unsigned int command, DCHECK(engine_); DCHECK_EQ(1u, command); DCHECK_EQ(1u, arg_count); - const CommandBufferEntry* args = - static_cast<const CommandBufferEntry*>(_args); - engine_->set_token(args[0].value_uint32); + const cmd::SetToken* args = + static_cast<const cmd::SetToken*>(_args); + engine_->set_token(args->token); } namespace gles2 { |