From 5e4d24d67febed160e2020f5c8f13d8073921fc4 Mon Sep 17 00:00:00 2001 From: "gman@chromium.org" Date: Tue, 9 Mar 2010 19:36:32 +0000 Subject: Add command buffer test for case where command inserted exactly matches the space left in the command buffer. TEST=unit test BUG=none Review URL: http://codereview.chromium.org/672009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41066 0039d316-1c4b-4281-b951-d872f2087c98 --- .../client/cmd_buffer_helper_test.cc | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'gpu') diff --git a/gpu/command_buffer/client/cmd_buffer_helper_test.cc b/gpu/command_buffer/client/cmd_buffer_helper_test.cc index 7ababa2..afbb117 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper_test.cc +++ b/gpu/command_buffer/client/cmd_buffer_helper_test.cc @@ -180,7 +180,7 @@ TEST_F(CommandBufferHelperTest, TestCommandProcessing) { TEST_F(CommandBufferHelperTest, TestCommandWrapping) { // Add 5 commands of size 3 through the helper to make sure we do wrap. CommandBufferEntry args1[2]; - args1[0].value_uint32 = 3; + args1[0].value_uint32 = 5; args1[1].value_float = 4.f; for (unsigned int i = 0; i < 5; ++i) { @@ -195,6 +195,30 @@ TEST_F(CommandBufferHelperTest, TestCommandWrapping) { EXPECT_EQ(error::kNoError, GetError()); } +// Checks the case where the command inserted exactly matches the space left in +// the command buffer. +TEST_F(CommandBufferHelperTest, TestCommandWrappingExactMultiple) { + const int32 kCommandSize = 5; + const int32 kNumArgs = kCommandSize - 1; + COMPILE_ASSERT(kNumCommandEntries % kCommandSize == 0, + Not_multiple_of_num_command_entries); + CommandBufferEntry args1[kNumArgs]; + for (size_t ii = 0; ii < kNumArgs; ++ii) { + args1[0].value_uint32 = ii + 1; + } + + for (unsigned int i = 0; i < 5; ++i) { + AddCommandWithExpect(error::kNoError, i + 1, kNumArgs, args1); + } + + helper_->Finish(); + // Check that the commands did happen. + Mock::VerifyAndClearExpectations(api_mock_.get()); + + // Check the error status. + EXPECT_EQ(error::kNoError, GetError()); +} + // Checks that asking for available entries work, and that the parser // effectively won't use that space. TEST_F(CommandBufferHelperTest, TestAvailableEntries) { -- cgit v1.1