blob: 20bad1bd84bf95f533f4473006f03c018a559a82 [file] [log] [blame]
[email protected]a93bb842010-02-16 23:03:471// 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
3// found in the LICENSE file.
4
5#include "gpu/command_buffer/service/shader_manager.h"
6#include "testing/gtest/include/gtest/gtest.h"
7
8namespace gpu {
9namespace gles2 {
10
11class ShaderManagerTest : public testing::Test {
12 public:
13 ShaderManagerTest() {
14 }
15
16 protected:
17 virtual void SetUp() {
18 }
19
20 virtual void TearDown() {
21 }
22
23 ShaderManager manager_;
24};
25
26TEST_F(ShaderManagerTest, Basic) {
27 const GLuint kShader1Id = 1;
28 const std::string kShader1Source("hello world");
29 const GLuint kShader2Id = 2;
30 // Check we can create shader.
31 manager_.CreateShaderInfo(kShader1Id);
32 // Check shader got created.
33 ShaderManager::ShaderInfo* info1 = manager_.GetShaderInfo(kShader1Id);
34 ASSERT_TRUE(info1 != NULL);
35 // Check we and set its source.
36 info1->Update(kShader1Source);
37 EXPECT_STREQ(kShader1Source.c_str(), info1->source().c_str());
38 // Check we get nothing for a non-existent shader.
39 EXPECT_TRUE(manager_.GetShaderInfo(kShader2Id) == NULL);
40 // Check trying to a remove non-existent shaders does not crash.
41 manager_.RemoveShaderInfo(kShader2Id);
42 // Check we can't get the shader after we remove it.
43 manager_.RemoveShaderInfo(kShader1Id);
44 EXPECT_TRUE(manager_.GetShaderInfo(kShader1Id) == NULL);
45}
46
47} // namespace gles2
48} // namespace gpu
49
50