| OLD | NEW |
| 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 Loading... |
| 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[0]", true, 6u, 0, true); |
| 215 CheckParseUniformName("u_name[2]", true, 6u, 2, true); |
| 216 CheckParseUniformName("u_name[02]", true, 6u, 2, true); |
| 217 CheckParseUniformName("u_name[20]", true, 6u, 20, true); |
| 218 CheckParseUniformName("u_name[020]", true, 6u, 20, true); |
| 219 CheckParseUniformName("u_name[0][0]", true, 9u, 0, true); |
| 220 CheckParseUniformName("u_name[3][2]", true, 9u, 2, true); |
| 221 CheckParseUniformName("u_name[03][02]", true, 10u, 2, true); |
| 222 CheckParseUniformName("u_name[30][20]", true, 10u, 20, true); |
| 223 CheckParseUniformName("u_name[030][020]", true, 11u, 20, true); |
| 224 } |
| 225 |
| 184 } // namespace gles2 | 226 } // namespace gles2 |
| 185 } // namespace gpu | 227 } // namespace gpu |
| 186 | 228 |
| OLD | NEW |