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

Side by Side Diff: gpu/command_buffer/common/gles2_cmd_utils_unittest.cc

Issue 10855274: Fix Uniform Name Parsing (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/gles2_cmd_utils.h" 5 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA)); 174 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA));
175 EXPECT_EQ( 175 EXPECT_EQ(
176 4u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH24_STENCIL8_OES)); 176 4u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH24_STENCIL8_OES));
177 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB8_OES)); 177 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB8_OES));
178 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA8_OES)); 178 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA8_OES));
179 EXPECT_EQ( 179 EXPECT_EQ(
180 4u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH_COMPONENT24_OES)); 180 4u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH_COMPONENT24_OES));
181 EXPECT_EQ(0u, GLES2Util::RenderbufferBytesPerPixel(-1)); 181 EXPECT_EQ(0u, GLES2Util::RenderbufferBytesPerPixel(-1));
182 } 182 }
183 183
184 namespace {
185
186 void CheckParseUniformName(
187 const char* name,
188 bool expected_success,
189 size_t expected_array_pos,
190 int expected_index,
191 bool expected_getting_array) {
192 int index = 1234;
193 size_t array_pos = 1244;
194 bool getting_array = false;
195 bool success = GLES2Util::ParseUniformName(
196 name, &array_pos, &index, &getting_array);
197 EXPECT_EQ(expected_success, success);
198 if (success) {
199 EXPECT_EQ(expected_array_pos, array_pos);
200 EXPECT_EQ(expected_index, index);
201 EXPECT_EQ(expected_getting_array, getting_array);
202 }
203 }
204
205 } // anonymous namespace
206
207 TEST_F(GLES2UtilTest, ParseUniformName) {
208 CheckParseUniformName("u_name", true, std::string::npos, 0, false);
209 CheckParseUniformName("u_name[]", false, std::string::npos, 0, false);
210 CheckParseUniformName("u_name]", false, std::string::npos, 0, false);
211 CheckParseUniformName("u_name[0a]", false, std::string::npos, 0, false);
212 CheckParseUniformName("u_name[a0]", false, std::string::npos, 0, false);
213 CheckParseUniformName("u_name[0a0]", false, std::string::npos, 0, false);
214 CheckParseUniformName("u_name[0a0]", false, std::string::npos, 0, false);
Zhenyao Mo 2012/08/21 22:03:37 This is the same as the above line
215 CheckParseUniformName("u_name[0]", true, 6u, 0, true);
216 CheckParseUniformName("u_name[2]", true, 6u, 2, true);
217 CheckParseUniformName("u_name[02]", true, 6u, 2, true);
218 CheckParseUniformName("u_name[20]", true, 6u, 20, true);
219 CheckParseUniformName("u_name[020]", true, 6u, 20, true);
220 CheckParseUniformName("u_name[0][0]", true, 9u, 0, true);
221 CheckParseUniformName("u_name[3][2]", true, 9u, 2, true);
222 CheckParseUniformName("u_name[03][02]", true, 10u, 2, true);
223 CheckParseUniformName("u_name[30][20]", true, 10u, 20, true);
224 CheckParseUniformName("u_name[030][020]", true, 11u, 20, true);
225 }
226
184 } // namespace gles2 227 } // namespace gles2
185 } // namespace gpu 228 } // namespace gpu
186 229
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698