| 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 3233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3244 init_options.lose_context_when_out_of_memory = true; | 3244 init_options.lose_context_when_out_of_memory = true; |
| 3245 ASSERT_TRUE(Initialize(init_options)); | 3245 ASSERT_TRUE(Initialize(init_options)); |
| 3246 | 3246 |
| 3247 struct Cmds { | 3247 struct Cmds { |
| 3248 cmds::LoseContextCHROMIUM cmd; | 3248 cmds::LoseContextCHROMIUM cmd; |
| 3249 }; | 3249 }; |
| 3250 | 3250 |
| 3251 GLsizei max = std::numeric_limits<GLsizei>::max(); | 3251 GLsizei max = std::numeric_limits<GLsizei>::max(); |
| 3252 EXPECT_CALL(*gpu_control_, CreateGpuMemoryBuffer(max, max, _, _)) | 3252 EXPECT_CALL(*gpu_control_, CreateGpuMemoryBuffer(max, max, _, _)) |
| 3253 .WillOnce(Return(static_cast<gfx::GpuMemoryBuffer*>(NULL))); | 3253 .WillOnce(Return(static_cast<gfx::GpuMemoryBuffer*>(NULL))); |
| 3254 gl_->CreateImageCHROMIUM(max, max, 0); | 3254 gl_->CreateImageCHROMIUM(max, max, 0, GL_READ_WRITE); |
| 3255 // The context should be lost. | 3255 // The context should be lost. |
| 3256 Cmds expected; | 3256 Cmds expected; |
| 3257 expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_UNKNOWN_CONTEXT_RESET_ARB); | 3257 expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_UNKNOWN_CONTEXT_RESET_ARB); |
| 3258 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 3258 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 3259 } | 3259 } |
| 3260 | 3260 |
| 3261 TEST_F(GLES2ImplementationManualInitTest, NoLoseContextOnOOM) { | 3261 TEST_F(GLES2ImplementationManualInitTest, NoLoseContextOnOOM) { |
| 3262 ContextInitOptions init_options; | 3262 ContextInitOptions init_options; |
| 3263 ASSERT_TRUE(Initialize(init_options)); | 3263 ASSERT_TRUE(Initialize(init_options)); |
| 3264 | 3264 |
| 3265 struct Cmds { | 3265 struct Cmds { |
| 3266 cmds::LoseContextCHROMIUM cmd; | 3266 cmds::LoseContextCHROMIUM cmd; |
| 3267 }; | 3267 }; |
| 3268 | 3268 |
| 3269 GLsizei max = std::numeric_limits<GLsizei>::max(); | 3269 GLsizei max = std::numeric_limits<GLsizei>::max(); |
| 3270 EXPECT_CALL(*gpu_control_, CreateGpuMemoryBuffer(max, max, _, _)) | 3270 EXPECT_CALL(*gpu_control_, CreateGpuMemoryBuffer(max, max, _, _)) |
| 3271 .WillOnce(Return(static_cast<gfx::GpuMemoryBuffer*>(NULL))); | 3271 .WillOnce(Return(static_cast<gfx::GpuMemoryBuffer*>(NULL))); |
| 3272 gl_->CreateImageCHROMIUM(max, max, 0); | 3272 gl_->CreateImageCHROMIUM(max, max, 0, GL_READ_WRITE); |
| 3273 // The context should not be lost. | 3273 // The context should not be lost. |
| 3274 EXPECT_TRUE(NoCommandsWritten()); | 3274 EXPECT_TRUE(NoCommandsWritten()); |
| 3275 } | 3275 } |
| 3276 | 3276 |
| 3277 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch1) { | 3277 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch1) { |
| 3278 ContextInitOptions init_options; | 3278 ContextInitOptions init_options; |
| 3279 init_options.bind_generates_resource_client = false; | 3279 init_options.bind_generates_resource_client = false; |
| 3280 init_options.bind_generates_resource_service = true; | 3280 init_options.bind_generates_resource_service = true; |
| 3281 EXPECT_FALSE(Initialize(init_options)); | 3281 EXPECT_FALSE(Initialize(init_options)); |
| 3282 } | 3282 } |
| 3283 | 3283 |
| 3284 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch2) { | 3284 TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch2) { |
| 3285 ContextInitOptions init_options; | 3285 ContextInitOptions init_options; |
| 3286 init_options.bind_generates_resource_client = true; | 3286 init_options.bind_generates_resource_client = true; |
| 3287 init_options.bind_generates_resource_service = false; | 3287 init_options.bind_generates_resource_service = false; |
| 3288 EXPECT_FALSE(Initialize(init_options)); | 3288 EXPECT_FALSE(Initialize(init_options)); |
| 3289 } | 3289 } |
| 3290 | 3290 |
| 3291 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 3291 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
| 3292 | 3292 |
| 3293 } // namespace gles2 | 3293 } // namespace gles2 |
| 3294 } // namespace gpu | 3294 } // namespace gpu |
| OLD | NEW |