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

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

Issue 1696012: Added shader type to shader info. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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) 2010 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 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace gpu { 8 namespace gpu {
9 namespace gles2 { 9 namespace gles2 {
10 10
11 class ShaderManagerTest : public testing::Test { 11 class ShaderManagerTest : public testing::Test {
12 public: 12 public:
13 ShaderManagerTest() { 13 ShaderManagerTest() {
14 } 14 }
15 15
16 protected: 16 protected:
17 virtual void SetUp() { 17 virtual void SetUp() {
18 } 18 }
19 19
20 virtual void TearDown() { 20 virtual void TearDown() {
21 } 21 }
22 22
23 ShaderManager manager_; 23 ShaderManager manager_;
24 }; 24 };
25 25
26 TEST_F(ShaderManagerTest, Basic) { 26 TEST_F(ShaderManagerTest, Basic) {
27 const GLuint kClient1Id = 1; 27 const GLuint kClient1Id = 1;
28 const GLuint kService1Id = 11; 28 const GLuint kService1Id = 11;
29 const GLenum kShader1Type = GL_VERTEX_SHADER;
29 const std::string kClient1Source("hello world"); 30 const std::string kClient1Source("hello world");
30 const GLuint kClient2Id = 2; 31 const GLuint kClient2Id = 2;
31 // Check we can create shader. 32 // Check we can create shader.
32 manager_.CreateShaderInfo(kClient1Id, kService1Id); 33 manager_.CreateShaderInfo(kClient1Id, kService1Id, kShader1Type);
33 // Check shader got created. 34 // Check shader got created.
34 ShaderManager::ShaderInfo* info1 = manager_.GetShaderInfo(kClient1Id); 35 ShaderManager::ShaderInfo* info1 = manager_.GetShaderInfo(kClient1Id);
35 ASSERT_TRUE(info1 != NULL); 36 ASSERT_TRUE(info1 != NULL);
36 EXPECT_EQ(kService1Id, info1->service_id()); 37 EXPECT_EQ(kService1Id, info1->service_id());
37 // Check we and set its source. 38 // Check if the shader has correct type.
39 EXPECT_EQ(kShader1Type, info1->shader_type());
40 // Check we can set its source.
38 info1->Update(kClient1Source); 41 info1->Update(kClient1Source);
39 EXPECT_STREQ(kClient1Source.c_str(), info1->source().c_str()); 42 EXPECT_STREQ(kClient1Source.c_str(), info1->source().c_str());
40 // Check we get nothing for a non-existent shader. 43 // Check we get nothing for a non-existent shader.
41 EXPECT_TRUE(manager_.GetShaderInfo(kClient2Id) == NULL); 44 EXPECT_TRUE(manager_.GetShaderInfo(kClient2Id) == NULL);
42 // Check trying to a remove non-existent shaders does not crash. 45 // Check trying to a remove non-existent shaders does not crash.
43 manager_.RemoveShaderInfo(kClient2Id); 46 manager_.RemoveShaderInfo(kClient2Id);
44 // Check we can't get the shader after we remove it. 47 // Check we can't get the shader after we remove it.
45 manager_.RemoveShaderInfo(kClient1Id); 48 manager_.RemoveShaderInfo(kClient1Id);
46 EXPECT_TRUE(manager_.GetShaderInfo(kClient1Id) == NULL); 49 EXPECT_TRUE(manager_.GetShaderInfo(kClient1Id) == NULL);
47 } 50 }
48 51
49 } // namespace gles2 52 } // namespace gles2
50 } // namespace gpu 53 } // namespace gpu
51 54
52 55
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