OLD | NEW |
1 // Copyright (c) 2011 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_translator.h" | 5 #include "gpu/command_buffer/service/shader_translator.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 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // There should be one attribute with following characteristics: | 137 // There should be one attribute with following characteristics: |
138 // name:vPosition type:SH_FLOAT_VEC4 size:1. | 138 // name:vPosition type:SH_FLOAT_VEC4 size:1. |
139 const ShaderTranslator::VariableMap& attrib_map = | 139 const ShaderTranslator::VariableMap& attrib_map = |
140 vertex_translator_.attrib_map(); | 140 vertex_translator_.attrib_map(); |
141 EXPECT_EQ(1u, attrib_map.size()); | 141 EXPECT_EQ(1u, attrib_map.size()); |
142 ShaderTranslator::VariableMap::const_iterator iter = | 142 ShaderTranslator::VariableMap::const_iterator iter = |
143 attrib_map.find("vPosition"); | 143 attrib_map.find("vPosition"); |
144 EXPECT_TRUE(iter != attrib_map.end()); | 144 EXPECT_TRUE(iter != attrib_map.end()); |
145 EXPECT_EQ(SH_FLOAT_VEC4, iter->second.type); | 145 EXPECT_EQ(SH_FLOAT_VEC4, iter->second.type); |
146 EXPECT_EQ(1, iter->second.size); | 146 EXPECT_EQ(1, iter->second.size); |
| 147 EXPECT_EQ("vPosition", iter->second.name); |
147 } | 148 } |
148 | 149 |
149 TEST_F(ShaderTranslatorTest, GetUniforms) { | 150 TEST_F(ShaderTranslatorTest, GetUniforms) { |
150 const char* shader = | 151 const char* shader = |
151 "precision mediump float;\n" | 152 "precision mediump float;\n" |
152 "struct Foo {\n" | 153 "struct Foo {\n" |
153 " vec4 color[1];\n" | 154 " vec4 color[1];\n" |
154 "};\n" | 155 "};\n" |
155 "struct Bar {\n" | 156 "struct Bar {\n" |
156 " Foo foo;\n" | 157 " Foo foo;\n" |
(...skipping 16 matching lines...) Expand all Loading... |
173 // 2. name:bar[1].foo.color[0] type:SH_FLOAT_VEC4 size:1 | 174 // 2. name:bar[1].foo.color[0] type:SH_FLOAT_VEC4 size:1 |
174 const ShaderTranslator::VariableMap& uniform_map = | 175 const ShaderTranslator::VariableMap& uniform_map = |
175 fragment_translator_.uniform_map(); | 176 fragment_translator_.uniform_map(); |
176 EXPECT_EQ(2u, uniform_map.size()); | 177 EXPECT_EQ(2u, uniform_map.size()); |
177 // First uniform. | 178 // First uniform. |
178 ShaderTranslator::VariableMap::const_iterator iter = | 179 ShaderTranslator::VariableMap::const_iterator iter = |
179 uniform_map.find("bar[0].foo.color[0]"); | 180 uniform_map.find("bar[0].foo.color[0]"); |
180 EXPECT_TRUE(iter != uniform_map.end()); | 181 EXPECT_TRUE(iter != uniform_map.end()); |
181 EXPECT_EQ(SH_FLOAT_VEC4, iter->second.type); | 182 EXPECT_EQ(SH_FLOAT_VEC4, iter->second.type); |
182 EXPECT_EQ(1, iter->second.size); | 183 EXPECT_EQ(1, iter->second.size); |
| 184 EXPECT_EQ("bar[0].foo.color[0]", iter->second.name); |
183 // Second uniform. | 185 // Second uniform. |
184 iter = uniform_map.find("bar[1].foo.color[0]"); | 186 iter = uniform_map.find("bar[1].foo.color[0]"); |
185 EXPECT_TRUE(iter != uniform_map.end()); | 187 EXPECT_TRUE(iter != uniform_map.end()); |
186 EXPECT_EQ(SH_FLOAT_VEC4, iter->second.type); | 188 EXPECT_EQ(SH_FLOAT_VEC4, iter->second.type); |
187 EXPECT_EQ(1, iter->second.size); | 189 EXPECT_EQ(1, iter->second.size); |
| 190 EXPECT_EQ("bar[1].foo.color[0]", iter->second.name); |
188 } | 191 } |
189 | 192 |
190 } // namespace gles2 | 193 } // namespace gles2 |
191 } // namespace gpu | 194 } // namespace gpu |
192 | 195 |
OLD | NEW |