| 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 GLES2Implementation. | 5 // Tests for GLES2Implementation. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 3565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3576 struct Cmds { | 3576 struct Cmds { |
| 3577 cmds::IsEnabled cmd; | 3577 cmds::IsEnabled cmd; |
| 3578 }; | 3578 }; |
| 3579 | 3579 |
| 3580 Cmds expected; | 3580 Cmds expected; |
| 3581 ExpectedMemoryInfo result1 = | 3581 ExpectedMemoryInfo result1 = |
| 3582 GetExpectedResultMemory(sizeof(cmds::IsEnabled::Result)); | 3582 GetExpectedResultMemory(sizeof(cmds::IsEnabled::Result)); |
| 3583 expected.cmd.Init(kCap, result1.id, result1.offset); | 3583 expected.cmd.Init(kCap, result1.id, result1.offset); |
| 3584 | 3584 |
| 3585 EXPECT_CALL(*command_buffer(), OnFlush()) | 3585 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 3586 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) | 3586 .WillOnce(SetMemory(result1.ptr, uint32_t(kCap))) |
| 3587 .RetiresOnSaturation(); | 3587 .RetiresOnSaturation(); |
| 3588 | 3588 |
| 3589 GLboolean result = gl_->IsEnabled(kCap); | 3589 GLboolean result = gl_->IsEnabled(kCap); |
| 3590 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 3590 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 3591 EXPECT_TRUE(result); | 3591 EXPECT_TRUE(result); |
| 3592 } | 3592 } |
| 3593 | 3593 |
| 3594 TEST_F(GLES2ImplementationTest, ClientWaitSync) { | |
| 3595 const GLuint client_sync_id = 36; | |
| 3596 struct Cmds { | |
| 3597 cmds::ClientWaitSync cmd; | |
| 3598 }; | |
| 3599 | |
| 3600 Cmds expected; | |
| 3601 ExpectedMemoryInfo result1 = | |
| 3602 GetExpectedResultMemory(sizeof(cmds::ClientWaitSync::Result)); | |
| 3603 const GLuint64 kTimeout = 0xABCDEF0123456789; | |
| 3604 uint32_t v32_0 = 0, v32_1 = 0; | |
| 3605 GLES2Util::MapUint64ToTwoUint32(kTimeout, &v32_0, &v32_1); | |
| 3606 expected.cmd.Init(client_sync_id, GL_SYNC_FLUSH_COMMANDS_BIT, | |
| 3607 v32_0, v32_1, result1.id, result1.offset); | |
| 3608 | |
| 3609 EXPECT_CALL(*command_buffer(), OnFlush()) | |
| 3610 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_CONDITION_SATISFIED))) | |
| 3611 .RetiresOnSaturation(); | |
| 3612 | |
| 3613 GLenum result = gl_->ClientWaitSync( | |
| 3614 reinterpret_cast<GLsync>(client_sync_id), GL_SYNC_FLUSH_COMMANDS_BIT, | |
| 3615 kTimeout); | |
| 3616 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | |
| 3617 EXPECT_EQ(static_cast<GLenum>(GL_CONDITION_SATISFIED), result); | |
| 3618 } | |
| 3619 | |
| 3620 TEST_F(GLES2ImplementationTest, WaitSync) { | |
| 3621 const GLuint kClientSyncId = 36; | |
| 3622 struct Cmds { | |
| 3623 cmds::WaitSync cmd; | |
| 3624 }; | |
| 3625 Cmds expected; | |
| 3626 const GLuint64 kTimeout = GL_TIMEOUT_IGNORED; | |
| 3627 uint32_t v32_0 = 0, v32_1 = 0; | |
| 3628 GLES2Util::MapUint64ToTwoUint32(kTimeout, &v32_0, &v32_1); | |
| 3629 expected.cmd.Init(kClientSyncId, 0, v32_0, v32_1); | |
| 3630 | |
| 3631 gl_->WaitSync(reinterpret_cast<GLsync>(kClientSyncId), 0, kTimeout); | |
| 3632 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | |
| 3633 } | |
| 3634 | |
| 3635 TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) { | 3594 TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) { |
| 3636 ContextInitOptions init_options; | 3595 ContextInitOptions init_options; |
| 3637 init_options.lose_context_when_out_of_memory = true; | 3596 init_options.lose_context_when_out_of_memory = true; |
| 3638 ASSERT_TRUE(Initialize(init_options)); | 3597 ASSERT_TRUE(Initialize(init_options)); |
| 3639 | 3598 |
| 3640 struct Cmds { | 3599 struct Cmds { |
| 3641 cmds::LoseContextCHROMIUM cmd; | 3600 cmds::LoseContextCHROMIUM cmd; |
| 3642 }; | 3601 }; |
| 3643 | 3602 |
| 3644 GLsizei max = std::numeric_limits<GLsizei>::max(); | 3603 GLsizei max = std::numeric_limits<GLsizei>::max(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3684 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { | 3643 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { |
| 3685 ContextInitOptions init_options; | 3644 ContextInitOptions init_options; |
| 3686 init_options.transfer_buffer_initialize_fail = true; | 3645 init_options.transfer_buffer_initialize_fail = true; |
| 3687 EXPECT_FALSE(Initialize(init_options)); | 3646 EXPECT_FALSE(Initialize(init_options)); |
| 3688 } | 3647 } |
| 3689 | 3648 |
| 3690 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 3649 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
| 3691 | 3650 |
| 3692 } // namespace gles2 | 3651 } // namespace gles2 |
| 3693 } // namespace gpu | 3652 } // namespace gpu |
| OLD | NEW |