| 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 3351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3362 TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) { | 3362 TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) { |
| 3363 ContextInitOptions init_options; | 3363 ContextInitOptions init_options; |
| 3364 init_options.lose_context_when_out_of_memory = true; | 3364 init_options.lose_context_when_out_of_memory = true; |
| 3365 ASSERT_TRUE(Initialize(init_options)); | 3365 ASSERT_TRUE(Initialize(init_options)); |
| 3366 | 3366 |
| 3367 struct Cmds { | 3367 struct Cmds { |
| 3368 cmds::LoseContextCHROMIUM cmd; | 3368 cmds::LoseContextCHROMIUM cmd; |
| 3369 }; | 3369 }; |
| 3370 | 3370 |
| 3371 GLsizei max = std::numeric_limits<GLsizei>::max(); | 3371 GLsizei max = std::numeric_limits<GLsizei>::max(); |
| 3372 EXPECT_CALL(*gpu_control_, CreateGpuMemoryBuffer(max, max, _, _, _)) | 3372 EXPECT_CALL(*gpu_control_, CreateGpuMemoryBufferImage(max, max, _, _)) |
| 3373 .WillOnce(Return(static_cast<gfx::GpuMemoryBuffer*>(NULL))); | 3373 .WillOnce(Return(-1)); |
| 3374 gl_->CreateImageCHROMIUM(max, max, 0, GL_IMAGE_MAP_CHROMIUM); | 3374 gl_->CreateGpuMemoryBufferImageCHROMIUM(max, max, GL_RGBA, GL_MAP_CHROMIUM); |
| 3375 // The context should be lost. | 3375 // The context should be lost. |
| 3376 Cmds expected; | 3376 Cmds expected; |
| 3377 expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_UNKNOWN_CONTEXT_RESET_ARB); | 3377 expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_UNKNOWN_CONTEXT_RESET_ARB); |
| 3378 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 3378 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 3379 } | 3379 } |
| 3380 | 3380 |
| 3381 TEST_F(GLES2ImplementationManualInitTest, NoLoseContextOnOOM) { | 3381 TEST_F(GLES2ImplementationManualInitTest, NoLoseContextOnOOM) { |
| 3382 ContextInitOptions init_options; | 3382 ContextInitOptions init_options; |
| 3383 ASSERT_TRUE(Initialize(init_options)); | 3383 ASSERT_TRUE(Initialize(init_options)); |
| 3384 | 3384 |
| 3385 struct Cmds { | 3385 struct Cmds { |
| 3386 cmds::LoseContextCHROMIUM cmd; | 3386 cmds::LoseContextCHROMIUM cmd; |
| 3387 }; | 3387 }; |
| 3388 | 3388 |
| 3389 GLsizei max = std::numeric_limits<GLsizei>::max(); | 3389 GLsizei max = std::numeric_limits<GLsizei>::max(); |
| 3390 EXPECT_CALL(*gpu_control_, CreateGpuMemoryBuffer(max, max, _, _, _)) | 3390 EXPECT_CALL(*gpu_control_, CreateGpuMemoryBufferImage(max, max, _, _)) |
| 3391 .WillOnce(Return(static_cast<gfx::GpuMemoryBuffer*>(NULL))); | 3391 .WillOnce(Return(-1)); |
| 3392 gl_->CreateImageCHROMIUM(max, max, 0, GL_IMAGE_MAP_CHROMIUM); | 3392 gl_->CreateGpuMemoryBufferImageCHROMIUM(max, max, GL_RGBA, GL_MAP_CHROMIUM); |
| 3393 // The context should not be lost. | 3393 // The context should not be lost. |
| 3394 EXPECT_TRUE(NoCommandsWritten()); | 3394 EXPECT_TRUE(NoCommandsWritten()); |
| 3395 } | 3395 } |
| 3396 | 3396 |
| 3397 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch1) { | 3397 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch1) { |
| 3398 ContextInitOptions init_options; | 3398 ContextInitOptions init_options; |
| 3399 init_options.bind_generates_resource_client = false; | 3399 init_options.bind_generates_resource_client = false; |
| 3400 init_options.bind_generates_resource_service = true; | 3400 init_options.bind_generates_resource_service = true; |
| 3401 EXPECT_FALSE(Initialize(init_options)); | 3401 EXPECT_FALSE(Initialize(init_options)); |
| 3402 } | 3402 } |
| 3403 | 3403 |
| 3404 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch2) { | 3404 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch2) { |
| 3405 ContextInitOptions init_options; | 3405 ContextInitOptions init_options; |
| 3406 init_options.bind_generates_resource_client = true; | 3406 init_options.bind_generates_resource_client = true; |
| 3407 init_options.bind_generates_resource_service = false; | 3407 init_options.bind_generates_resource_service = false; |
| 3408 EXPECT_FALSE(Initialize(init_options)); | 3408 EXPECT_FALSE(Initialize(init_options)); |
| 3409 } | 3409 } |
| 3410 | 3410 |
| 3411 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 3411 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
| 3412 | 3412 |
| 3413 } // namespace gles2 | 3413 } // namespace gles2 |
| 3414 } // namespace gpu | 3414 } // namespace gpu |
| OLD | NEW |