| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 Buffer Helper. | 5 // Tests for the Command Buffer Helper. |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 464 |
| 465 // Check the error status. | 465 // Check the error status. |
| 466 EXPECT_EQ(error::kNoError, GetError()); | 466 EXPECT_EQ(error::kNoError, GetError()); |
| 467 } | 467 } |
| 468 | 468 |
| 469 // Checks that commands in the buffer are properly executed when wrapping the | 469 // Checks that commands in the buffer are properly executed when wrapping the |
| 470 // buffer, and that the status/error stay valid. | 470 // buffer, and that the status/error stay valid. |
| 471 TEST_F(CommandBufferHelperTest, TestCommandWrapping) { | 471 TEST_F(CommandBufferHelperTest, TestCommandWrapping) { |
| 472 // Add num_commands * commands of size 3 through the helper to make sure we | 472 // Add num_commands * commands of size 3 through the helper to make sure we |
| 473 // do wrap. kTotalNumCommandEntries must not be a multiple of 3. | 473 // do wrap. kTotalNumCommandEntries must not be a multiple of 3. |
| 474 COMPILE_ASSERT(kTotalNumCommandEntries % 3 != 0, | 474 static_assert(kTotalNumCommandEntries % 3 != 0, |
| 475 Is_multiple_of_num_command_entries); | 475 "kTotalNumCommandEntries must not be a multiple of 3"); |
| 476 const int kNumCommands = (kTotalNumCommandEntries / 3) * 2; | 476 const int kNumCommands = (kTotalNumCommandEntries / 3) * 2; |
| 477 CommandBufferEntry args1[2]; | 477 CommandBufferEntry args1[2]; |
| 478 args1[0].value_uint32 = 5; | 478 args1[0].value_uint32 = 5; |
| 479 args1[1].value_float = 4.f; | 479 args1[1].value_float = 4.f; |
| 480 | 480 |
| 481 for (int i = 0; i < kNumCommands; ++i) { | 481 for (int i = 0; i < kNumCommands; ++i) { |
| 482 AddCommandWithExpect(error::kNoError, kUnusedCommandId + i, 2, args1); | 482 AddCommandWithExpect(error::kNoError, kUnusedCommandId + i, 2, args1); |
| 483 } | 483 } |
| 484 | 484 |
| 485 helper_->Finish(); | 485 helper_->Finish(); |
| 486 // Check that the commands did happen. | 486 // Check that the commands did happen. |
| 487 Mock::VerifyAndClearExpectations(api_mock_.get()); | 487 Mock::VerifyAndClearExpectations(api_mock_.get()); |
| 488 | 488 |
| 489 // Check the error status. | 489 // Check the error status. |
| 490 EXPECT_EQ(error::kNoError, GetError()); | 490 EXPECT_EQ(error::kNoError, GetError()); |
| 491 } | 491 } |
| 492 | 492 |
| 493 // Checks the case where the command inserted exactly matches the space left in | 493 // Checks the case where the command inserted exactly matches the space left in |
| 494 // the command buffer. | 494 // the command buffer. |
| 495 TEST_F(CommandBufferHelperTest, TestCommandWrappingExactMultiple) { | 495 TEST_F(CommandBufferHelperTest, TestCommandWrappingExactMultiple) { |
| 496 const int32 kCommandSize = kTotalNumCommandEntries / 2; | 496 const int32 kCommandSize = kTotalNumCommandEntries / 2; |
| 497 const size_t kNumArgs = kCommandSize - 1; | 497 const size_t kNumArgs = kCommandSize - 1; |
| 498 COMPILE_ASSERT(kTotalNumCommandEntries % kCommandSize == 0, | 498 static_assert(kTotalNumCommandEntries % kCommandSize == 0, |
| 499 Not_multiple_of_num_command_entries); | 499 "kTotalNumCommandEntries should be a multiple of kCommandSize"); |
| 500 CommandBufferEntry args1[kNumArgs]; | 500 CommandBufferEntry args1[kNumArgs]; |
| 501 for (size_t ii = 0; ii < kNumArgs; ++ii) { | 501 for (size_t ii = 0; ii < kNumArgs; ++ii) { |
| 502 args1[ii].value_uint32 = ii + 1; | 502 args1[ii].value_uint32 = ii + 1; |
| 503 } | 503 } |
| 504 | 504 |
| 505 for (unsigned int i = 0; i < 5; ++i) { | 505 for (unsigned int i = 0; i < 5; ++i) { |
| 506 AddCommandWithExpect( | 506 AddCommandWithExpect( |
| 507 error::kNoError, i + kUnusedCommandId, kNumArgs, args1); | 507 error::kNoError, i + kUnusedCommandId, kNumArgs, args1); |
| 508 } | 508 } |
| 509 | 509 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 helper_->Finish(); | 703 helper_->Finish(); |
| 704 | 704 |
| 705 // Check that the commands did happen. | 705 // Check that the commands did happen. |
| 706 Mock::VerifyAndClearExpectations(api_mock_.get()); | 706 Mock::VerifyAndClearExpectations(api_mock_.get()); |
| 707 | 707 |
| 708 // Check the error status. | 708 // Check the error status. |
| 709 EXPECT_EQ(error::kNoError, GetError()); | 709 EXPECT_EQ(error::kNoError, GetError()); |
| 710 } | 710 } |
| 711 | 711 |
| 712 } // namespace gpu | 712 } // namespace gpu |
| OLD | NEW |