| 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 3185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3196 } | 3196 } |
| 3197 | 3197 |
| 3198 TEST_F(GLES2ImplementationTest, GetString) { | 3198 TEST_F(GLES2ImplementationTest, GetString) { |
| 3199 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; | 3199 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; |
| 3200 const Str7 kString = {"foobar"}; | 3200 const Str7 kString = {"foobar"}; |
| 3201 // GL_CHROMIUM_map_sub is hard coded into GLES2Implementation. | 3201 // GL_CHROMIUM_map_sub is hard coded into GLES2Implementation. |
| 3202 const char* expected_str = | 3202 const char* expected_str = |
| 3203 "foobar " | 3203 "foobar " |
| 3204 "GL_EXT_unpack_subimage " | 3204 "GL_EXT_unpack_subimage " |
| 3205 "GL_CHROMIUM_map_sub " | 3205 "GL_CHROMIUM_map_sub " |
| 3206 "GL_CHROMIUM_image " | 3206 "GL_CHROMIUM_image"; |
| 3207 "GL_CHROMIUM_gpu_memory_buffer_image"; | |
| 3208 const char kBad = 0x12; | 3207 const char kBad = 0x12; |
| 3209 struct Cmds { | 3208 struct Cmds { |
| 3210 cmd::SetBucketSize set_bucket_size1; | 3209 cmd::SetBucketSize set_bucket_size1; |
| 3211 cmds::GetString get_string; | 3210 cmds::GetString get_string; |
| 3212 cmd::GetBucketStart get_bucket_start; | 3211 cmd::GetBucketStart get_bucket_start; |
| 3213 cmd::SetToken set_token1; | 3212 cmd::SetToken set_token1; |
| 3214 cmd::SetBucketSize set_bucket_size2; | 3213 cmd::SetBucketSize set_bucket_size2; |
| 3215 }; | 3214 }; |
| 3216 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 3215 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 3217 ExpectedMemoryInfo result1 = | 3216 ExpectedMemoryInfo result1 = |
| (...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4602 EXPECT_EQ(0, lost_count); | 4601 EXPECT_EQ(0, lost_count); |
| 4603 | 4602 |
| 4604 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetGraphicsResetStatusKHR()); | 4603 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetGraphicsResetStatusKHR()); |
| 4605 gl_as_client->OnGpuControlLostContextMaybeReentrant(); | 4604 gl_as_client->OnGpuControlLostContextMaybeReentrant(); |
| 4606 EXPECT_NE(static_cast<GLenum>(GL_NO_ERROR), gl_->GetGraphicsResetStatusKHR()); | 4605 EXPECT_NE(static_cast<GLenum>(GL_NO_ERROR), gl_->GetGraphicsResetStatusKHR()); |
| 4607 // The lost context callback should not be run yet to avoid calling back into | 4606 // The lost context callback should not be run yet to avoid calling back into |
| 4608 // clients re-entrantly, and having them re-enter GLES2Implementation. | 4607 // clients re-entrantly, and having them re-enter GLES2Implementation. |
| 4609 EXPECT_EQ(0, lost_count); | 4608 EXPECT_EQ(0, lost_count); |
| 4610 } | 4609 } |
| 4611 | 4610 |
| 4612 TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) { | |
| 4613 ContextInitOptions init_options; | |
| 4614 init_options.lose_context_when_out_of_memory = true; | |
| 4615 ASSERT_TRUE(Initialize(init_options)); | |
| 4616 | |
| 4617 struct Cmds { | |
| 4618 cmds::LoseContextCHROMIUM cmd; | |
| 4619 }; | |
| 4620 | |
| 4621 GLsizei max = std::numeric_limits<GLsizei>::max(); | |
| 4622 EXPECT_CALL(*gpu_control_, CreateGpuMemoryBufferImage(max, max, _, _)) | |
| 4623 .WillOnce(Return(-1)); | |
| 4624 gl_->CreateGpuMemoryBufferImageCHROMIUM(max, max, GL_RGBA, | |
| 4625 GL_READ_WRITE_CHROMIUM); | |
| 4626 // The context should be lost. | |
| 4627 Cmds expected; | |
| 4628 expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_UNKNOWN_CONTEXT_RESET_ARB); | |
| 4629 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | |
| 4630 } | |
| 4631 | |
| 4632 TEST_F(GLES2ImplementationManualInitTest, NoLoseContextOnOOM) { | |
| 4633 ContextInitOptions init_options; | |
| 4634 ASSERT_TRUE(Initialize(init_options)); | |
| 4635 | |
| 4636 struct Cmds { | |
| 4637 cmds::LoseContextCHROMIUM cmd; | |
| 4638 }; | |
| 4639 | |
| 4640 GLsizei max = std::numeric_limits<GLsizei>::max(); | |
| 4641 EXPECT_CALL(*gpu_control_, CreateGpuMemoryBufferImage(max, max, _, _)) | |
| 4642 .WillOnce(Return(-1)); | |
| 4643 gl_->CreateGpuMemoryBufferImageCHROMIUM(max, max, GL_RGBA, | |
| 4644 GL_READ_WRITE_CHROMIUM); | |
| 4645 // The context should not be lost. | |
| 4646 EXPECT_TRUE(NoCommandsWritten()); | |
| 4647 } | |
| 4648 | |
| 4649 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch1) { | 4611 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch1) { |
| 4650 ContextInitOptions init_options; | 4612 ContextInitOptions init_options; |
| 4651 init_options.bind_generates_resource_client = false; | 4613 init_options.bind_generates_resource_client = false; |
| 4652 init_options.bind_generates_resource_service = true; | 4614 init_options.bind_generates_resource_service = true; |
| 4653 EXPECT_FALSE(Initialize(init_options)); | 4615 EXPECT_FALSE(Initialize(init_options)); |
| 4654 } | 4616 } |
| 4655 | 4617 |
| 4656 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch2) { | 4618 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch2) { |
| 4657 ContextInitOptions init_options; | 4619 ContextInitOptions init_options; |
| 4658 init_options.bind_generates_resource_client = true; | 4620 init_options.bind_generates_resource_client = true; |
| 4659 init_options.bind_generates_resource_service = false; | 4621 init_options.bind_generates_resource_service = false; |
| 4660 EXPECT_FALSE(Initialize(init_options)); | 4622 EXPECT_FALSE(Initialize(init_options)); |
| 4661 } | 4623 } |
| 4662 | 4624 |
| 4663 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { | 4625 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { |
| 4664 ContextInitOptions init_options; | 4626 ContextInitOptions init_options; |
| 4665 init_options.transfer_buffer_initialize_fail = true; | 4627 init_options.transfer_buffer_initialize_fail = true; |
| 4666 EXPECT_FALSE(Initialize(init_options)); | 4628 EXPECT_FALSE(Initialize(init_options)); |
| 4667 } | 4629 } |
| 4668 | 4630 |
| 4669 #include "base/macros.h" | 4631 #include "base/macros.h" |
| 4670 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 4632 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
| 4671 | 4633 |
| 4672 } // namespace gles2 | 4634 } // namespace gles2 |
| 4673 } // namespace gpu | 4635 } // namespace gpu |
| OLD | NEW |