Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: gpu/command_buffer/service/shader_manager_unittest.cc

Issue 6721010: Fix bug in shader and program managers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/shader_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "gpu/command_buffer/common/gl_mock.h" 8 #include "gpu/command_buffer/common/gl_mock.h"
9 #include "gpu/command_buffer/service/mocks.h" 9 #include "gpu/command_buffer/service/mocks.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 ASSERT_TRUE(info1 != NULL); 68 ASSERT_TRUE(info1 != NULL);
69 EXPECT_CALL(*gl_, DeleteShader(kService1Id)) 69 EXPECT_CALL(*gl_, DeleteShader(kService1Id))
70 .Times(1) 70 .Times(1)
71 .RetiresOnSaturation(); 71 .RetiresOnSaturation();
72 manager_.Destroy(true); 72 manager_.Destroy(true);
73 // Check that resources got freed. 73 // Check that resources got freed.
74 info1 = manager_.GetShaderInfo(kClient1Id); 74 info1 = manager_.GetShaderInfo(kClient1Id);
75 ASSERT_TRUE(info1 == NULL); 75 ASSERT_TRUE(info1 == NULL);
76 } 76 }
77 77
78 TEST_F(ShaderManagerTest, DeleteBug) {
79 const GLuint kClient1Id = 1;
80 const GLuint kClient2Id = 2;
81 const GLuint kService1Id = 11;
82 const GLuint kService2Id = 12;
83 const GLenum kShaderType = GL_VERTEX_SHADER;
84 // Check we can create shader.
85 manager_.CreateShaderInfo(kClient1Id, kService1Id, kShaderType);
86 manager_.CreateShaderInfo(kClient2Id, kService2Id, kShaderType);
87 ShaderManager::ShaderInfo::Ref info1(manager_.GetShaderInfo(kClient1Id));
88 ShaderManager::ShaderInfo::Ref info2(manager_.GetShaderInfo(kClient2Id));
89 ASSERT_TRUE(info1.get() != NULL);
90 ASSERT_TRUE(info2.get() != NULL);
91 manager_.UseShader(info1);
92 manager_.MarkAsDeleted(info1);
93 manager_.MarkAsDeleted(info2);
94 EXPECT_TRUE(manager_.IsOwned(info1));
95 EXPECT_FALSE(manager_.IsOwned(info2));
96 }
97
78 TEST_F(ShaderManagerTest, ShaderInfo) { 98 TEST_F(ShaderManagerTest, ShaderInfo) {
79 const GLuint kClient1Id = 1; 99 const GLuint kClient1Id = 1;
80 const GLuint kService1Id = 11; 100 const GLuint kService1Id = 11;
81 const GLenum kShader1Type = GL_VERTEX_SHADER; 101 const GLenum kShader1Type = GL_VERTEX_SHADER;
82 const char* kClient1Source = "hello world"; 102 const char* kClient1Source = "hello world";
83 // Check we can create shader. 103 // Check we can create shader.
84 manager_.CreateShaderInfo(kClient1Id, kService1Id, kShader1Type); 104 manager_.CreateShaderInfo(kClient1Id, kService1Id, kShader1Type);
85 // Check shader got created. 105 // Check shader got created.
86 ShaderManager::ShaderInfo* info1 = manager_.GetShaderInfo(kClient1Id); 106 ShaderManager::ShaderInfo* info1 = manager_.GetShaderInfo(kClient1Id);
87 ASSERT_TRUE(info1 != NULL); 107 ASSERT_TRUE(info1 != NULL);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 EXPECT_EQ(info1, info2); 233 EXPECT_EQ(info1, info2);
214 manager_.MarkAsDeleted(info1); // this should delete the shader. 234 manager_.MarkAsDeleted(info1); // this should delete the shader.
215 info2 = manager_.GetShaderInfo(kClient1Id); 235 info2 = manager_.GetShaderInfo(kClient1Id);
216 EXPECT_TRUE(info2 == NULL); 236 EXPECT_TRUE(info2 == NULL);
217 } 237 }
218 238
219 } // namespace gles2 239 } // namespace gles2
220 } // namespace gpu 240 } // namespace gpu
221 241
222 242
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/shader_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698