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 #include "gpu/command_buffer/service/shader_manager.h" | 5 #include "gpu/command_buffer/service/shader_manager.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "gpu/command_buffer/service/gpu_service_test.h" | 8 #include "gpu/command_buffer/service/gpu_service_test.h" |
9 #include "gpu/command_buffer/service/mocks.h" | 9 #include "gpu/command_buffer/service/mocks.h" |
10 #include "gpu/command_buffer/service/test_helper.h" | 10 #include "gpu/command_buffer/service/test_helper.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 const GLuint kService2Id = 12; | 75 const GLuint kService2Id = 12; |
76 const GLenum kShaderType = GL_VERTEX_SHADER; | 76 const GLenum kShaderType = GL_VERTEX_SHADER; |
77 // Check we can create shader. | 77 // Check we can create shader. |
78 scoped_refptr<Shader> shader1( | 78 scoped_refptr<Shader> shader1( |
79 manager_.CreateShader(kClient1Id, kService1Id, kShaderType)); | 79 manager_.CreateShader(kClient1Id, kService1Id, kShaderType)); |
80 scoped_refptr<Shader> shader2( | 80 scoped_refptr<Shader> shader2( |
81 manager_.CreateShader(kClient2Id, kService2Id, kShaderType)); | 81 manager_.CreateShader(kClient2Id, kService2Id, kShaderType)); |
82 ASSERT_TRUE(shader1.get()); | 82 ASSERT_TRUE(shader1.get()); |
83 ASSERT_TRUE(shader2.get()); | 83 ASSERT_TRUE(shader2.get()); |
84 manager_.UseShader(shader1.get()); | 84 manager_.UseShader(shader1.get()); |
85 EXPECT_CALL(*gl_, DeleteShader(kService1Id)) | |
86 .Times(1) | |
87 .RetiresOnSaturation(); | |
88 manager_.Delete(shader1.get()); | 85 manager_.Delete(shader1.get()); |
| 86 |
89 EXPECT_CALL(*gl_, DeleteShader(kService2Id)) | 87 EXPECT_CALL(*gl_, DeleteShader(kService2Id)) |
90 .Times(1) | 88 .Times(1) |
91 .RetiresOnSaturation(); | 89 .RetiresOnSaturation(); |
92 manager_.Delete(shader2.get()); | 90 manager_.Delete(shader2.get()); |
93 EXPECT_TRUE(manager_.IsOwned(shader1.get())); | 91 EXPECT_TRUE(manager_.IsOwned(shader1.get())); |
94 EXPECT_FALSE(manager_.IsOwned(shader2.get())); | 92 EXPECT_FALSE(manager_.IsOwned(shader2.get())); |
| 93 |
| 94 EXPECT_CALL(*gl_, DeleteShader(kService1Id)) |
| 95 .Times(1) |
| 96 .RetiresOnSaturation(); |
| 97 manager_.UnuseShader(shader1.get()); |
95 } | 98 } |
96 | 99 |
97 TEST_F(ShaderManagerTest, DoCompile) { | 100 TEST_F(ShaderManagerTest, DoCompile) { |
98 const GLuint kClient1Id = 1; | 101 const GLuint kClient1Id = 1; |
99 const GLuint kService1Id = 11; | 102 const GLuint kService1Id = 11; |
100 const GLenum kShader1Type = GL_VERTEX_SHADER; | 103 const GLenum kShader1Type = GL_VERTEX_SHADER; |
101 const char* kClient1Source = "hello world"; | 104 const char* kClient1Source = "hello world"; |
102 const GLenum kAttrib1Type = GL_FLOAT_VEC2; | 105 const GLenum kAttrib1Type = GL_FLOAT_VEC2; |
103 const GLint kAttrib1Size = 2; | 106 const GLint kAttrib1Size = 2; |
104 const GLenum kAttrib1Precision = GL_MEDIUM_FLOAT; | 107 const GLenum kAttrib1Precision = GL_MEDIUM_FLOAT; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 EXPECT_CALL(*gl_, DeleteShader(kService1Id)) | 290 EXPECT_CALL(*gl_, DeleteShader(kService1Id)) |
288 .Times(1) | 291 .Times(1) |
289 .RetiresOnSaturation(); | 292 .RetiresOnSaturation(); |
290 manager_.Delete(shader1); // this should delete the shader. | 293 manager_.Delete(shader1); // this should delete the shader. |
291 shader2 = manager_.GetShader(kClient1Id); | 294 shader2 = manager_.GetShader(kClient1Id); |
292 EXPECT_TRUE(shader2 == NULL); | 295 EXPECT_TRUE(shader2 == NULL); |
293 } | 296 } |
294 | 297 |
295 } // namespace gles2 | 298 } // namespace gles2 |
296 } // namespace gpu | 299 } // namespace gpu |
OLD | NEW |