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 <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
(...skipping 3866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3877 struct Cmds { | 3877 struct Cmds { |
3878 cmds::WaitSyncTokenCHROMIUM wait_sync_token; | 3878 cmds::WaitSyncTokenCHROMIUM wait_sync_token; |
3879 }; | 3879 }; |
3880 Cmds expected; | 3880 Cmds expected; |
3881 expected.wait_sync_token.Init(kNamespaceId, kCommandBufferId, kFenceSync); | 3881 expected.wait_sync_token.Init(kNamespaceId, kCommandBufferId, kFenceSync); |
3882 | 3882 |
3883 gl_->WaitSyncTokenCHROMIUM(sync_token); | 3883 gl_->WaitSyncTokenCHROMIUM(sync_token); |
3884 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 3884 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
3885 } | 3885 } |
3886 | 3886 |
| 3887 TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUMErrors) { |
| 3888 ExpectedMemoryInfo result = |
| 3889 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 3890 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 3891 .WillRepeatedly(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) |
| 3892 .RetiresOnSaturation(); |
| 3893 |
| 3894 // Empty sync tokens should be produce no error and be a nop. |
| 3895 ClearCommands(); |
| 3896 gl_->WaitSyncTokenCHROMIUM(nullptr); |
| 3897 EXPECT_TRUE(NoCommandsWritten()); |
| 3898 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
| 3899 |
| 3900 // Invalid sync tokens should produce no error and be a nop. |
| 3901 ClearCommands(); |
| 3902 gpu::SyncToken invalid_sync_token(CommandBufferNamespace::INVALID, 0, 0); |
| 3903 gl_->WaitSyncTokenCHROMIUM(invalid_sync_token.GetConstData()); |
| 3904 EXPECT_TRUE(NoCommandsWritten()); |
| 3905 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
| 3906 |
| 3907 // Unverified sync token should produce INVALID_OPERATION. |
| 3908 ClearCommands(); |
| 3909 gpu::SyncToken unverified_sync_token(CommandBufferNamespace::GPU_IO, 0, 0); |
| 3910 EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_)) |
| 3911 .WillOnce(testing::Return(false)); |
| 3912 gl_->WaitSyncTokenCHROMIUM(unverified_sync_token.GetConstData()); |
| 3913 EXPECT_TRUE(NoCommandsWritten()); |
| 3914 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
| 3915 } |
| 3916 |
3887 TEST_F(GLES2ImplementationTest, IsEnabled) { | 3917 TEST_F(GLES2ImplementationTest, IsEnabled) { |
3888 // If we use a valid enum, its state is cached on client side, so no command | 3918 // If we use a valid enum, its state is cached on client side, so no command |
3889 // is actually generated, and this test will fail. | 3919 // is actually generated, and this test will fail. |
3890 // TODO(zmo): it seems we never need the command. Maybe remove it. | 3920 // TODO(zmo): it seems we never need the command. Maybe remove it. |
3891 GLenum kCap = 1; | 3921 GLenum kCap = 1; |
3892 struct Cmds { | 3922 struct Cmds { |
3893 cmds::IsEnabled cmd; | 3923 cmds::IsEnabled cmd; |
3894 }; | 3924 }; |
3895 | 3925 |
3896 Cmds expected; | 3926 Cmds expected; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4167 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { | 4197 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { |
4168 ContextInitOptions init_options; | 4198 ContextInitOptions init_options; |
4169 init_options.transfer_buffer_initialize_fail = true; | 4199 init_options.transfer_buffer_initialize_fail = true; |
4170 EXPECT_FALSE(Initialize(init_options)); | 4200 EXPECT_FALSE(Initialize(init_options)); |
4171 } | 4201 } |
4172 | 4202 |
4173 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 4203 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
4174 | 4204 |
4175 } // namespace gles2 | 4205 } // namespace gles2 |
4176 } // namespace gpu | 4206 } // namespace gpu |
OLD | NEW |