Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1236)

Unified Diff: gpu/command_buffer/service/cmd_parser_test.cc

Issue 8919014: Revert "Revert 113479 - Revert "Revert 113250 - Add CommandBuffer::SetGetBuffer"" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/cmd_parser.cc ('k') | gpu/command_buffer/service/command_buffer_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/cmd_parser_test.cc
diff --git a/gpu/command_buffer/service/cmd_parser_test.cc b/gpu/command_buffer/service/cmd_parser_test.cc
index 857ca8e6e163da9b1d5d9329da2d6840034bb2ed..b86b0afe3620923d3f2e06cf571a66950580475e 100644
--- a/gpu/command_buffer/service/cmd_parser_test.cc
+++ b/gpu/command_buffer/service/cmd_parser_test.cc
@@ -48,12 +48,10 @@ class CommandParserTest : public testing::Test {
size_t command_buffer_size = entry_count *
sizeof(CommandBufferEntry); // NOLINT
DCHECK_LE(command_buffer_size, shm_size);
- return new CommandParser(buffer(),
- shm_size,
- 0,
- command_buffer_size,
- 0,
- api_mock());
+ CommandParser* parser = new CommandParser(api_mock());
+
+ parser->SetBuffer(buffer(), shm_size, 0, command_buffer_size);
+ return parser;
}
unsigned int buffer_entry_count() { return 20; }
@@ -288,4 +286,34 @@ TEST_F(CommandParserTest, TestError) {
Mock::VerifyAndClearExpectations(api_mock());
}
+TEST_F(CommandParserTest, SetBuffer) {
+ scoped_ptr<CommandParser> parser(MakeParser(3));
+ CommandBufferOffset put = parser->put();
+ CommandHeader header;
+
+ // add a single command, no args
+ header.size = 2;
+ header.command = 123;
+ buffer()[put++].value_header = header;
+ buffer()[put++].value_int32 = 456;
+
+ CommandBufferEntry param_array[1];
+ param_array[0].value_int32 = 456;
+
+ parser->set_put(put);
+ AddDoCommandExpect(error::kNoError, 123, 1, param_array);
+ EXPECT_EQ(error::kNoError, parser->ProcessAllCommands());
+ // We should have advanced 2 entries
+ EXPECT_EQ(2, parser->get());
+ Mock::VerifyAndClearExpectations(api_mock());
+
+ scoped_array<CommandBufferEntry> buffer2(new CommandBufferEntry[2]);
+ parser->SetBuffer(
+ buffer2.get(), sizeof(CommandBufferEntry) * 2, 0,
+ sizeof(CommandBufferEntry) * 2);
+ // The put and get should have reset to 0.
+ EXPECT_EQ(0, parser->get());
+ EXPECT_EQ(0, parser->put());
+}
+
} // namespace gpu
« no previous file with comments | « gpu/command_buffer/service/cmd_parser.cc ('k') | gpu/command_buffer/service/command_buffer_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698