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 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 | 1417 |
1418 TEST_P(GLES2DecoderTest, LoseContextCHROMIUMInvalidArgs1_0) { | 1418 TEST_P(GLES2DecoderTest, LoseContextCHROMIUMInvalidArgs1_0) { |
1419 EXPECT_CALL(*mock_decoder_, MarkContextLost(_)) | 1419 EXPECT_CALL(*mock_decoder_, MarkContextLost(_)) |
1420 .Times(0); | 1420 .Times(0); |
1421 cmds::LoseContextCHROMIUM cmd; | 1421 cmds::LoseContextCHROMIUM cmd; |
1422 cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_NONE); | 1422 cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_NONE); |
1423 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1423 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1424 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | 1424 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
1425 } | 1425 } |
1426 | 1426 |
| 1427 TEST_P(GLES3DecoderTest, TransformFeedbackStates) { |
| 1428 cmds::BeginTransformFeedback begin_cmd; |
| 1429 begin_cmd.Init(GL_POINTS); |
| 1430 cmds::EndTransformFeedback end_cmd; |
| 1431 end_cmd.Init(); |
| 1432 cmds::PauseTransformFeedback pause_cmd; |
| 1433 pause_cmd.Init(); |
| 1434 cmds::ResumeTransformFeedback resume_cmd; |
| 1435 resume_cmd.Init(); |
| 1436 |
| 1437 // Before Begin: Pause, Resume, and End is invalid. |
| 1438 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
| 1439 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1440 |
| 1441 EXPECT_EQ(error::kNoError, ExecuteCmd(pause_cmd)); |
| 1442 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1443 |
| 1444 EXPECT_EQ(error::kNoError, ExecuteCmd(resume_cmd)); |
| 1445 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1446 |
| 1447 // Begin |
| 1448 EXPECT_CALL(*gl_, BeginTransformFeedback(GL_POINTS)) |
| 1449 .Times(1) |
| 1450 .RetiresOnSaturation(); |
| 1451 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 1452 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1453 |
| 1454 // Begin again is invalid. |
| 1455 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 1456 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1457 |
| 1458 // Before Pause: Resume is invalid. |
| 1459 EXPECT_EQ(error::kNoError, ExecuteCmd(resume_cmd)); |
| 1460 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1461 |
| 1462 // Pause |
| 1463 EXPECT_CALL(*gl_, PauseTransformFeedback()) |
| 1464 .Times(1) |
| 1465 .RetiresOnSaturation(); |
| 1466 EXPECT_EQ(error::kNoError, ExecuteCmd(pause_cmd)); |
| 1467 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1468 |
| 1469 // Pause again is invalid. |
| 1470 EXPECT_EQ(error::kNoError, ExecuteCmd(pause_cmd)); |
| 1471 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1472 |
| 1473 // Resume |
| 1474 EXPECT_CALL(*gl_, ResumeTransformFeedback()) |
| 1475 .Times(1) |
| 1476 .RetiresOnSaturation(); |
| 1477 EXPECT_EQ(error::kNoError, ExecuteCmd(resume_cmd)); |
| 1478 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1479 |
| 1480 // End |
| 1481 EXPECT_CALL(*gl_, EndTransformFeedback()) |
| 1482 .Times(1) |
| 1483 .RetiresOnSaturation(); |
| 1484 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
| 1485 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1486 } |
| 1487 |
1427 class GLES2DecoderDoCommandsTest : public GLES2DecoderTest { | 1488 class GLES2DecoderDoCommandsTest : public GLES2DecoderTest { |
1428 public: | 1489 public: |
1429 GLES2DecoderDoCommandsTest() { | 1490 GLES2DecoderDoCommandsTest() { |
1430 for (int i = 0; i < 3; i++) { | 1491 for (int i = 0; i < 3; i++) { |
1431 cmds_[i].Init(GL_BLEND); | 1492 cmds_[i].Init(GL_BLEND); |
1432 } | 1493 } |
1433 entries_per_cmd_ = ComputeNumEntries(cmds_[0].ComputeSize()); | 1494 entries_per_cmd_ = ComputeNumEntries(cmds_[0].ComputeSize()); |
1434 } | 1495 } |
1435 | 1496 |
1436 void SetExpectationsForNCommands(int num_commands) { | 1497 void SetExpectationsForNCommands(int num_commands) { |
1437 for (int i = 0; i < num_commands; i++) | 1498 for (int i = 0; i < num_commands; i++) |
1438 SetupExpectationsForEnableDisable(GL_BLEND, true); | 1499 SetupExpectationsForEnableDisable(GL_BLEND, true); |
1439 } | 1500 } |
1440 | 1501 |
1441 protected: | 1502 protected: |
1442 Enable cmds_[3]; | 1503 Enable cmds_[3]; |
1443 int entries_per_cmd_; | 1504 int entries_per_cmd_; |
1444 }; | 1505 }; |
1445 | 1506 |
| 1507 TEST_P(GLES3DecoderTest, BindTransformFeedbackValidArgs) { |
| 1508 EXPECT_CALL(*gl_, BindTransformFeedback(GL_TRANSFORM_FEEDBACK, |
| 1509 kServiceTransformFeedbackId)); |
| 1510 SpecializedSetup<cmds::BindTransformFeedback, 0>(true); |
| 1511 cmds::BindTransformFeedback cmd; |
| 1512 cmd.Init(GL_TRANSFORM_FEEDBACK, client_transformfeedback_id_); |
| 1513 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1514 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1515 } |
| 1516 |
| 1517 TEST_P(GLES3DecoderTest, GenDeleteTransformFeedbacksImmediateValidArgs) { |
| 1518 EXPECT_CALL(*gl_, GenTransformFeedbacks(1, _)) |
| 1519 .WillOnce(SetArgPointee<1>(kNewServiceId)); |
| 1520 cmds::GenTransformFeedbacksImmediate* gen_cmd = |
| 1521 GetImmediateAs<cmds::GenTransformFeedbacksImmediate>(); |
| 1522 GLuint temp = kNewClientId; |
| 1523 SpecializedSetup<cmds::GenTransformFeedbacksImmediate, 0>(true); |
| 1524 gen_cmd->Init(1, &temp); |
| 1525 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(*gen_cmd, sizeof(temp))); |
| 1526 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1527 EXPECT_TRUE(GetTransformFeedback(kNewClientId) != nullptr); |
| 1528 |
| 1529 EXPECT_CALL(*gl_, |
| 1530 DeleteTransformFeedbacks(1, Pointee(kNewServiceId))) |
| 1531 .Times(1); |
| 1532 cmds::DeleteTransformFeedbacksImmediate& delete_cmd = |
| 1533 *GetImmediateAs<cmds::DeleteTransformFeedbacksImmediate>(); |
| 1534 SpecializedSetup<cmds::DeleteTransformFeedbacksImmediate, 0>(true); |
| 1535 delete_cmd.Init(1, &temp); |
| 1536 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(delete_cmd, sizeof(&temp))); |
| 1537 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1538 EXPECT_TRUE(GetTransformFeedback(kNewClientId) == nullptr); |
| 1539 } |
| 1540 |
| 1541 TEST_P(GLES3DecoderTest, DeleteTransformFeedbacksImmediateInvalidArgs) { |
| 1542 cmds::DeleteTransformFeedbacksImmediate& cmd = |
| 1543 *GetImmediateAs<cmds::DeleteTransformFeedbacksImmediate>(); |
| 1544 SpecializedSetup<cmds::DeleteTransformFeedbacksImmediate, 0>(false); |
| 1545 GLuint temp = kInvalidClientId; |
| 1546 cmd.Init(1, &temp); |
| 1547 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); |
| 1548 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1549 } |
| 1550 |
| 1551 TEST_P(GLES3DecoderTest, GenTransformFeedbacksImmediateInvalidArgs) { |
| 1552 EXPECT_CALL(*gl_, GenTransformFeedbacks(_, _)).Times(0); |
| 1553 cmds::GenTransformFeedbacksImmediate* cmd = |
| 1554 GetImmediateAs<cmds::GenTransformFeedbacksImmediate>(); |
| 1555 SpecializedSetup<cmds::GenTransformFeedbacksImmediate, 0>(false); |
| 1556 cmd->Init(1, &client_transformfeedback_id_); |
| 1557 EXPECT_EQ(error::kInvalidArguments, |
| 1558 ExecuteImmediateCmd(*cmd, sizeof(&client_transformfeedback_id_))); |
| 1559 } |
| 1560 |
1446 // Test that processing with 0 entries does nothing. | 1561 // Test that processing with 0 entries does nothing. |
1447 TEST_P(GLES2DecoderDoCommandsTest, DoCommandsOneOfZero) { | 1562 TEST_P(GLES2DecoderDoCommandsTest, DoCommandsOneOfZero) { |
1448 int num_processed = -1; | 1563 int num_processed = -1; |
1449 SetExpectationsForNCommands(0); | 1564 SetExpectationsForNCommands(0); |
1450 EXPECT_EQ( | 1565 EXPECT_EQ( |
1451 error::kNoError, | 1566 error::kNoError, |
1452 decoder_->DoCommands(1, &cmds_, entries_per_cmd_ * 0, &num_processed)); | 1567 decoder_->DoCommands(1, &cmds_, entries_per_cmd_ * 0, &num_processed)); |
1453 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 1568 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
1454 EXPECT_EQ(0, num_processed); | 1569 EXPECT_EQ(0, num_processed); |
1455 } | 1570 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); | 1661 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); |
1547 | 1662 |
1548 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); | 1663 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); |
1549 | 1664 |
1550 INSTANTIATE_TEST_CASE_P(Service, | 1665 INSTANTIATE_TEST_CASE_P(Service, |
1551 GLES3DecoderWithESSL3ShaderTest, | 1666 GLES3DecoderWithESSL3ShaderTest, |
1552 ::testing::Bool()); | 1667 ::testing::Bool()); |
1553 | 1668 |
1554 } // namespace gles2 | 1669 } // namespace gles2 |
1555 } // namespace gpu | 1670 } // namespace gpu |
OLD | NEW |