| OLD | NEW |
| 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 kShader1Id = 1; | 27 const GLuint kClient1Id = 1; |
| 28 const std::string kShader1Source("hello world"); | 28 const GLuint kService1Id = 11; |
| 29 const GLuint kShader2Id = 2; | 29 const std::string kClient1Source("hello world"); |
| 30 const GLuint kClient2Id = 2; |
| 30 // Check we can create shader. | 31 // Check we can create shader. |
| 31 manager_.CreateShaderInfo(kShader1Id); | 32 manager_.CreateShaderInfo(kClient1Id, kService1Id); |
| 32 // Check shader got created. | 33 // Check shader got created. |
| 33 ShaderManager::ShaderInfo* info1 = manager_.GetShaderInfo(kShader1Id); | 34 ShaderManager::ShaderInfo* info1 = manager_.GetShaderInfo(kClient1Id); |
| 34 ASSERT_TRUE(info1 != NULL); | 35 ASSERT_TRUE(info1 != NULL); |
| 36 EXPECT_EQ(kService1Id, info1->service_id()); |
| 35 // Check we and set its source. | 37 // Check we and set its source. |
| 36 info1->Update(kShader1Source); | 38 info1->Update(kClient1Source); |
| 37 EXPECT_STREQ(kShader1Source.c_str(), info1->source().c_str()); | 39 EXPECT_STREQ(kClient1Source.c_str(), info1->source().c_str()); |
| 38 // Check we get nothing for a non-existent shader. | 40 // Check we get nothing for a non-existent shader. |
| 39 EXPECT_TRUE(manager_.GetShaderInfo(kShader2Id) == NULL); | 41 EXPECT_TRUE(manager_.GetShaderInfo(kClient2Id) == NULL); |
| 40 // Check trying to a remove non-existent shaders does not crash. | 42 // Check trying to a remove non-existent shaders does not crash. |
| 41 manager_.RemoveShaderInfo(kShader2Id); | 43 manager_.RemoveShaderInfo(kClient2Id); |
| 42 // Check we can't get the shader after we remove it. | 44 // Check we can't get the shader after we remove it. |
| 43 manager_.RemoveShaderInfo(kShader1Id); | 45 manager_.RemoveShaderInfo(kClient1Id); |
| 44 EXPECT_TRUE(manager_.GetShaderInfo(kShader1Id) == NULL); | 46 EXPECT_TRUE(manager_.GetShaderInfo(kClient1Id) == NULL); |
| 45 } | 47 } |
| 46 | 48 |
| 47 } // namespace gles2 | 49 } // namespace gles2 |
| 48 } // namespace gpu | 50 } // namespace gpu |
| 49 | 51 |
| 50 | 52 |
| OLD | NEW |