| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 parser. | 5 // Tests for the command parser. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/service/precompile.h" | 7 #include "gpu/command_buffer/service/precompile.h" |
| 8 | 8 |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "gpu/command_buffer/service/cmd_parser.h" | 10 #include "gpu/command_buffer/service/cmd_parser.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 AddDoCommandExpect(error::kNoError, 4, 1, ¶m); | 218 AddDoCommandExpect(error::kNoError, 4, 1, ¶m); |
| 219 parser->set_put(put); | 219 parser->set_put(put); |
| 220 EXPECT_EQ(put, parser->put()); | 220 EXPECT_EQ(put, parser->put()); |
| 221 EXPECT_EQ(error::kNoError, parser->ProcessAllCommands()); | 221 EXPECT_EQ(error::kNoError, parser->ProcessAllCommands()); |
| 222 EXPECT_EQ(put, parser->get()); | 222 EXPECT_EQ(put, parser->get()); |
| 223 Mock::VerifyAndClearExpectations(api_mock()); | 223 Mock::VerifyAndClearExpectations(api_mock()); |
| 224 } | 224 } |
| 225 | 225 |
| 226 // Tests error conditions. | 226 // Tests error conditions. |
| 227 TEST_F(CommandParserTest, TestError) { | 227 TEST_F(CommandParserTest, TestError) { |
| 228 scoped_ptr<CommandParser> parser(MakeParser(5)); | 228 const unsigned int kNumEntries = 5; |
| 229 scoped_ptr<CommandParser> parser(MakeParser(kNumEntries)); |
| 229 CommandBufferOffset put = parser->put(); | 230 CommandBufferOffset put = parser->put(); |
| 230 CommandHeader header; | 231 CommandHeader header; |
| 231 | 232 |
| 233 EXPECT_FALSE(parser->set_get(-1)); |
| 234 EXPECT_FALSE(parser->set_get(kNumEntries)); |
| 235 |
| 232 // Generate a command with size 0. | 236 // Generate a command with size 0. |
| 233 header.size = 0; | 237 header.size = 0; |
| 234 header.command = 3; | 238 header.command = 3; |
| 235 buffer()[put++].value_header = header; | 239 buffer()[put++].value_header = header; |
| 236 | 240 |
| 237 parser->set_put(put); | 241 parser->set_put(put); |
| 238 EXPECT_EQ(put, parser->put()); | 242 EXPECT_EQ(put, parser->put()); |
| 239 EXPECT_EQ(error::kInvalidSize, | 243 EXPECT_EQ(error::kInvalidSize, |
| 240 parser->ProcessAllCommands()); | 244 parser->ProcessAllCommands()); |
| 241 // check that no DoCommand call was made. | 245 // check that no DoCommand call was made. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 EXPECT_EQ(put_post_fail, parser->get()); | 283 EXPECT_EQ(put_post_fail, parser->get()); |
| 280 Mock::VerifyAndClearExpectations(api_mock()); | 284 Mock::VerifyAndClearExpectations(api_mock()); |
| 281 // make the second one succeed, and check that the parser recovered fine. | 285 // make the second one succeed, and check that the parser recovered fine. |
| 282 AddDoCommandExpect(error::kNoError, 4, 0, NULL); | 286 AddDoCommandExpect(error::kNoError, 4, 0, NULL); |
| 283 EXPECT_EQ(error::kNoError, parser->ProcessAllCommands()); | 287 EXPECT_EQ(error::kNoError, parser->ProcessAllCommands()); |
| 284 EXPECT_EQ(put, parser->get()); | 288 EXPECT_EQ(put, parser->get()); |
| 285 Mock::VerifyAndClearExpectations(api_mock()); | 289 Mock::VerifyAndClearExpectations(api_mock()); |
| 286 } | 290 } |
| 287 | 291 |
| 288 } // namespace gpu | 292 } // namespace gpu |
| OLD | NEW |