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

Side by Side Diff: gpu/command_buffer/tests/gl_program_unittest.cc

Issue 903273002: Update from https://crrev.com/315085 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <GLES2/gl2.h> 5 #include <GLES2/gl2.h>
6 #include <GLES2/gl2ext.h> 6 #include <GLES2/gl2ext.h>
7 7
8 #include "gpu/command_buffer/tests/gl_manager.h" 8 #include "gpu/command_buffer/tests/gl_manager.h"
9 #include "gpu/command_buffer/tests/gl_test_utils.h" 9 #include "gpu/command_buffer/tests/gl_test_utils.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 glLinkProgram(program); 114 glLinkProgram(program);
115 // We specifically don't call UseProgram again. 115 // We specifically don't call UseProgram again.
116 GLuint position_loc = glGetAttribLocation(program, "a_position"); 116 GLuint position_loc = glGetAttribLocation(program, "a_position");
117 GLTestHelper::SetupUnitQuad(position_loc); 117 GLTestHelper::SetupUnitQuad(position_loc);
118 glDrawArrays(GL_TRIANGLES, 0, 6); 118 glDrawArrays(GL_TRIANGLES, 0, 6);
119 uint8 expected_color[] = { 0, 0, 255, 255, }; 119 uint8 expected_color[] = { 0, 0, 255, 255, };
120 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color)); 120 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color));
121 GLTestHelper::CheckGLError("no errors", __LINE__); 121 GLTestHelper::CheckGLError("no errors", __LINE__);
122 } 122 }
123 123
124 TEST_F(GLProgramTest, ShaderLengthSpecified) {
125 const std::string valid_shader_str = SHADER(
126 attribute vec4 a_position;
127 void main()
128 {
129 gl_Position = a_position;
130 }
131 );
132
133 const std::string invalid_shader = valid_shader_str + "invalid suffix";
134
135 // Compiling invalid program should fail.
136 const char* invalid_shader_strings[] = { invalid_shader.c_str() };
137 GLuint vs = glCreateShader(GL_VERTEX_SHADER);
138 glShaderSource(vs, 1, invalid_shader_strings, NULL);
139 glCompileShader(vs);
140
141 GLint compile_state = 0;
142 glGetShaderiv(vs, GL_COMPILE_STATUS, &compile_state);
143 EXPECT_EQ(GL_FALSE, compile_state);
144
145 // Compiling program cutting off invalid parts should succeed.
146 const GLint lengths[] = { valid_shader_str.length() };
147 glShaderSource(vs, 1, invalid_shader_strings, lengths);
148 glCompileShader(vs);
149 glGetShaderiv(vs, GL_COMPILE_STATUS, &compile_state);
150 EXPECT_EQ(GL_TRUE, compile_state);
151 }
152
124 TEST_F(GLProgramTest, UniformsInCurrentProgram) { 153 TEST_F(GLProgramTest, UniformsInCurrentProgram) {
125 static const char* v_shader_str = SHADER( 154 static const char* v_shader_str = SHADER(
126 attribute vec4 a_position; 155 attribute vec4 a_position;
127 void main() 156 void main()
128 { 157 {
129 gl_Position = a_position; 158 gl_Position = a_position;
130 } 159 }
131 ); 160 );
132 static const char* f_shader_str = SHADER( 161 static const char* f_shader_str = SHADER(
133 precision mediump float; 162 precision mediump float;
(...skipping 19 matching lines...) Expand all
153 GLuint position_loc = glGetAttribLocation(program, "a_position"); 182 GLuint position_loc = glGetAttribLocation(program, "a_position");
154 GLTestHelper::SetupUnitQuad(position_loc); 183 GLTestHelper::SetupUnitQuad(position_loc);
155 glDrawArrays(GL_TRIANGLES, 0, 6); 184 glDrawArrays(GL_TRIANGLES, 0, 6);
156 uint8 expected_color[] = { 0, 0, 255, 255, }; 185 uint8 expected_color[] = { 0, 0, 255, 255, };
157 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color)); 186 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color));
158 GLTestHelper::CheckGLError("no errors", __LINE__); 187 GLTestHelper::CheckGLError("no errors", __LINE__);
159 } 188 }
160 189
161 } // namespace gpu 190 } // namespace gpu
162 191
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/test_helper.cc ('k') | gpu/command_buffer/tests/gl_unittests_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698