Don't add an aura tooltip to bubble close buttons on Windows.
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_decoder_unittest_programs.cc
blobafb9fc76558dac8a15fc15b2c4b612aa6b2a950a
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
3 // found in the LICENSE file.
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
11 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h"
12 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
13 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h"
14 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
15 #include "gpu/command_buffer/service/context_group.h"
16 #include "gpu/command_buffer/service/context_state.h"
17 #include "gpu/command_buffer/service/gl_surface_mock.h"
18 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
20 #include "gpu/command_buffer/service/gpu_switches.h"
21 #include "gpu/command_buffer/service/image_manager.h"
22 #include "gpu/command_buffer/service/mailbox_manager.h"
23 #include "gpu/command_buffer/service/mocks.h"
24 #include "gpu/command_buffer/service/program_manager.h"
25 #include "gpu/command_buffer/service/test_helper.h"
26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "ui/gl/gl_implementation.h"
28 #include "ui/gl/gl_mock.h"
29 #include "ui/gl/gl_surface_stub.h"
31 #if !defined(GL_DEPTH24_STENCIL8)
32 #define GL_DEPTH24_STENCIL8 0x88F0
33 #endif
35 using ::gfx::MockGLInterface;
36 using ::testing::_;
37 using ::testing::DoAll;
38 using ::testing::InSequence;
39 using ::testing::Invoke;
40 using ::testing::MatcherCast;
41 using ::testing::Mock;
42 using ::testing::Pointee;
43 using ::testing::Return;
44 using ::testing::SaveArg;
45 using ::testing::SetArrayArgument;
46 using ::testing::SetArgPointee;
47 using ::testing::StrEq;
48 using ::testing::StrictMock;
50 namespace gpu {
51 namespace gles2 {
53 using namespace cmds;
55 TEST_P(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMValidArgs) {
56 const uint32 kBucketId = 123;
57 GetProgramInfoCHROMIUM cmd;
58 cmd.Init(client_program_id_, kBucketId);
59 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
60 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
61 EXPECT_GT(bucket->size(), 0u);
64 TEST_P(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMInvalidArgs) {
65 const uint32 kBucketId = 123;
66 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
67 EXPECT_TRUE(bucket == NULL);
68 GetProgramInfoCHROMIUM cmd;
69 cmd.Init(kInvalidClientId, kBucketId);
70 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
71 EXPECT_EQ(GL_NO_ERROR, GetGLError());
72 bucket = decoder_->GetBucket(kBucketId);
73 ASSERT_TRUE(bucket != NULL);
74 EXPECT_EQ(sizeof(ProgramInfoHeader), bucket->size());
75 ProgramInfoHeader* info =
76 bucket->GetDataAs<ProgramInfoHeader*>(0, sizeof(ProgramInfoHeader));
77 ASSERT_TRUE(info != 0);
78 EXPECT_EQ(0u, info->link_status);
79 EXPECT_EQ(0u, info->num_attribs);
80 EXPECT_EQ(0u, info->num_uniforms);
83 TEST_P(GLES2DecoderWithShaderTest, GetUniformBlocksCHROMIUMValidArgs) {
84 const uint32 kBucketId = 123;
85 GetUniformBlocksCHROMIUM cmd;
86 cmd.Init(client_program_id_, kBucketId);
87 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
88 .WillOnce(SetArgPointee<2>(GL_TRUE))
89 .RetiresOnSaturation();
90 EXPECT_CALL(*gl_,
91 GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORM_BLOCKS, _))
92 .WillOnce(SetArgPointee<2>(0))
93 .RetiresOnSaturation();
94 decoder_->set_unsafe_es3_apis_enabled(true);
95 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
96 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
97 EXPECT_EQ(sizeof(UniformBlocksHeader), bucket->size());
98 UniformBlocksHeader* header =
99 bucket->GetDataAs<UniformBlocksHeader*>(0, sizeof(UniformBlocksHeader));
100 EXPECT_TRUE(header != NULL);
101 EXPECT_EQ(0u, header->num_uniform_blocks);
102 decoder_->set_unsafe_es3_apis_enabled(false);
103 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
106 TEST_P(GLES2DecoderWithShaderTest, GetUniformBlocksCHROMIUMInvalidArgs) {
107 const uint32 kBucketId = 123;
108 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
109 EXPECT_TRUE(bucket == NULL);
110 GetUniformBlocksCHROMIUM cmd;
111 cmd.Init(kInvalidClientId, kBucketId);
112 decoder_->set_unsafe_es3_apis_enabled(true);
113 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
114 EXPECT_EQ(GL_NO_ERROR, GetGLError());
115 bucket = decoder_->GetBucket(kBucketId);
116 ASSERT_TRUE(bucket != NULL);
117 EXPECT_EQ(sizeof(UniformBlocksHeader), bucket->size());
118 UniformBlocksHeader* header =
119 bucket->GetDataAs<UniformBlocksHeader*>(0, sizeof(UniformBlocksHeader));
120 ASSERT_TRUE(header != NULL);
121 EXPECT_EQ(0u, header->num_uniform_blocks);
124 TEST_P(GLES2DecoderWithShaderTest, GetUniformsES3CHROMIUMValidArgs) {
125 const uint32 kBucketId = 123;
126 GetUniformsES3CHROMIUM cmd;
127 cmd.Init(client_program_id_, kBucketId);
128 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
129 .WillOnce(SetArgPointee<2>(GL_TRUE))
130 .RetiresOnSaturation();
131 EXPECT_CALL(*gl_,
132 GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORMS, _))
133 .WillOnce(SetArgPointee<2>(0))
134 .RetiresOnSaturation();
135 decoder_->set_unsafe_es3_apis_enabled(true);
136 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
137 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
138 EXPECT_EQ(sizeof(UniformsES3Header), bucket->size());
139 UniformsES3Header* header =
140 bucket->GetDataAs<UniformsES3Header*>(0, sizeof(UniformsES3Header));
141 EXPECT_TRUE(header != NULL);
142 EXPECT_EQ(0u, header->num_uniforms);
143 decoder_->set_unsafe_es3_apis_enabled(false);
144 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
147 TEST_P(GLES2DecoderWithShaderTest, GetUniformsES3CHROMIUMInvalidArgs) {
148 const uint32 kBucketId = 123;
149 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
150 EXPECT_TRUE(bucket == NULL);
151 GetUniformsES3CHROMIUM cmd;
152 cmd.Init(kInvalidClientId, kBucketId);
153 decoder_->set_unsafe_es3_apis_enabled(true);
154 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
155 EXPECT_EQ(GL_NO_ERROR, GetGLError());
156 bucket = decoder_->GetBucket(kBucketId);
157 ASSERT_TRUE(bucket != NULL);
158 EXPECT_EQ(sizeof(UniformsES3Header), bucket->size());
159 UniformsES3Header* header =
160 bucket->GetDataAs<UniformsES3Header*>(0, sizeof(UniformsES3Header));
161 ASSERT_TRUE(header != NULL);
162 EXPECT_EQ(0u, header->num_uniforms);
165 TEST_P(GLES2DecoderWithShaderTest,
166 GetTransformFeedbackVaryingsCHROMIUMValidArgs) {
167 const uint32 kBucketId = 123;
168 GetTransformFeedbackVaryingsCHROMIUM cmd;
169 cmd.Init(client_program_id_, kBucketId);
170 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
171 .WillOnce(SetArgPointee<2>(GL_TRUE))
172 .RetiresOnSaturation();
173 EXPECT_CALL(*gl_,
174 GetProgramiv(
175 kServiceProgramId, GL_TRANSFORM_FEEDBACK_VARYINGS, _))
176 .WillOnce(SetArgPointee<2>(0))
177 .RetiresOnSaturation();
178 decoder_->set_unsafe_es3_apis_enabled(true);
179 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
180 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
181 EXPECT_EQ(sizeof(TransformFeedbackVaryingsHeader), bucket->size());
182 TransformFeedbackVaryingsHeader* header =
183 bucket->GetDataAs<TransformFeedbackVaryingsHeader*>(
184 0, sizeof(TransformFeedbackVaryingsHeader));
185 EXPECT_TRUE(header != NULL);
186 EXPECT_EQ(0u, header->num_transform_feedback_varyings);
187 decoder_->set_unsafe_es3_apis_enabled(false);
188 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
191 TEST_P(GLES2DecoderWithShaderTest,
192 GetTransformFeedbackVaryingsCHROMIUMInvalidArgs) {
193 const uint32 kBucketId = 123;
194 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
195 EXPECT_TRUE(bucket == NULL);
196 GetTransformFeedbackVaryingsCHROMIUM cmd;
197 cmd.Init(kInvalidClientId, kBucketId);
198 decoder_->set_unsafe_es3_apis_enabled(true);
199 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
200 EXPECT_EQ(GL_NO_ERROR, GetGLError());
201 bucket = decoder_->GetBucket(kBucketId);
202 ASSERT_TRUE(bucket != NULL);
203 EXPECT_EQ(sizeof(TransformFeedbackVaryingsHeader), bucket->size());
204 TransformFeedbackVaryingsHeader* header =
205 bucket->GetDataAs<TransformFeedbackVaryingsHeader*>(
206 0, sizeof(TransformFeedbackVaryingsHeader));
207 ASSERT_TRUE(header != NULL);
208 EXPECT_EQ(0u, header->num_transform_feedback_varyings);
211 TEST_P(GLES2DecoderWithShaderTest, GetUniformivSucceeds) {
212 GetUniformiv::Result* result =
213 static_cast<GetUniformiv::Result*>(shared_memory_address_);
214 result->size = 0;
215 GetUniformiv cmd;
216 cmd.Init(client_program_id_,
217 kUniform2FakeLocation,
218 kSharedMemoryId,
219 kSharedMemoryOffset);
220 EXPECT_CALL(*gl_, GetUniformiv(kServiceProgramId, kUniform2RealLocation, _))
221 .Times(1);
222 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
223 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
224 result->size);
227 TEST_P(GLES2DecoderWithShaderTest, GetUniformivArrayElementSucceeds) {
228 GetUniformiv::Result* result =
229 static_cast<GetUniformiv::Result*>(shared_memory_address_);
230 result->size = 0;
231 GetUniformiv cmd;
232 cmd.Init(client_program_id_,
233 kUniform2ElementFakeLocation,
234 kSharedMemoryId,
235 kSharedMemoryOffset);
236 EXPECT_CALL(*gl_,
237 GetUniformiv(kServiceProgramId, kUniform2ElementRealLocation, _))
238 .Times(1);
239 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
240 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
241 result->size);
244 TEST_P(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) {
245 GetUniformiv::Result* result =
246 static_cast<GetUniformiv::Result*>(shared_memory_address_);
247 result->size = 0;
248 GetUniformiv cmd;
249 // non-existant program
250 cmd.Init(kInvalidClientId,
251 kUniform2FakeLocation,
252 kSharedMemoryId,
253 kSharedMemoryOffset);
254 EXPECT_CALL(*gl_, GetUniformiv(_, _, _)).Times(0);
255 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
256 EXPECT_EQ(0U, result->size);
257 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
258 // Valid id that is not a program. The GL spec requires a different error for
259 // this case.
260 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS
261 result->size = kInitialResult;
262 cmd.Init(client_shader_id_,
263 kUniform2FakeLocation,
264 kSharedMemoryId,
265 kSharedMemoryOffset);
266 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
267 EXPECT_EQ(0U, result->size);
268 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
269 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS
270 // Unlinked program
271 EXPECT_CALL(*gl_, CreateProgram())
272 .Times(1)
273 .WillOnce(Return(kNewServiceId))
274 .RetiresOnSaturation();
275 CreateProgram cmd2;
276 cmd2.Init(kNewClientId);
277 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
278 result->size = kInitialResult;
279 cmd.Init(kNewClientId,
280 kUniform2FakeLocation,
281 kSharedMemoryId,
282 kSharedMemoryOffset);
283 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
284 EXPECT_EQ(0U, result->size);
285 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
288 TEST_P(GLES2DecoderWithShaderTest, GetUniformivBadLocationFails) {
289 GetUniformiv::Result* result =
290 static_cast<GetUniformiv::Result*>(shared_memory_address_);
291 result->size = 0;
292 GetUniformiv cmd;
293 // invalid location
294 cmd.Init(client_program_id_,
295 kInvalidUniformLocation,
296 kSharedMemoryId,
297 kSharedMemoryOffset);
298 EXPECT_CALL(*gl_, GetUniformiv(_, _, _)).Times(0);
299 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
300 EXPECT_EQ(0U, result->size);
301 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
304 TEST_P(GLES2DecoderWithShaderTest, GetUniformivBadSharedMemoryFails) {
305 GetUniformiv cmd;
306 cmd.Init(client_program_id_,
307 kUniform2FakeLocation,
308 kInvalidSharedMemoryId,
309 kSharedMemoryOffset);
310 EXPECT_CALL(*gl_, GetUniformiv(_, _, _)).Times(0);
311 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
312 cmd.Init(client_program_id_,
313 kUniform2FakeLocation,
314 kSharedMemoryId,
315 kInvalidSharedMemoryOffset);
316 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
319 TEST_P(GLES2DecoderWithShaderTest, GetUniformfvSucceeds) {
320 GetUniformfv::Result* result =
321 static_cast<GetUniformfv::Result*>(shared_memory_address_);
322 result->size = 0;
323 GetUniformfv cmd;
324 cmd.Init(client_program_id_,
325 kUniform2FakeLocation,
326 kSharedMemoryId,
327 kSharedMemoryOffset);
328 EXPECT_CALL(*gl_, GetUniformfv(kServiceProgramId, kUniform2RealLocation, _))
329 .Times(1);
330 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
331 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
332 result->size);
335 TEST_P(GLES2DecoderWithShaderTest, GetUniformfvArrayElementSucceeds) {
336 GetUniformfv::Result* result =
337 static_cast<GetUniformfv::Result*>(shared_memory_address_);
338 result->size = 0;
339 GetUniformfv cmd;
340 cmd.Init(client_program_id_,
341 kUniform2ElementFakeLocation,
342 kSharedMemoryId,
343 kSharedMemoryOffset);
344 EXPECT_CALL(*gl_,
345 GetUniformfv(kServiceProgramId, kUniform2ElementRealLocation, _))
346 .Times(1);
347 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
348 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
349 result->size);
352 TEST_P(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) {
353 GetUniformfv::Result* result =
354 static_cast<GetUniformfv::Result*>(shared_memory_address_);
355 result->size = 0;
356 GetUniformfv cmd;
357 // non-existant program
358 cmd.Init(kInvalidClientId,
359 kUniform2FakeLocation,
360 kSharedMemoryId,
361 kSharedMemoryOffset);
362 EXPECT_CALL(*gl_, GetUniformfv(_, _, _)).Times(0);
363 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
364 EXPECT_EQ(0U, result->size);
365 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
366 // Valid id that is not a program. The GL spec requires a different error for
367 // this case.
368 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS
369 result->size = kInitialResult;
370 cmd.Init(client_shader_id_,
371 kUniform2FakeLocation,
372 kSharedMemoryId,
373 kSharedMemoryOffset);
374 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
375 EXPECT_EQ(0U, result->size);
376 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
377 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS
378 // Unlinked program
379 EXPECT_CALL(*gl_, CreateProgram())
380 .Times(1)
381 .WillOnce(Return(kNewServiceId))
382 .RetiresOnSaturation();
383 CreateProgram cmd2;
384 cmd2.Init(kNewClientId);
385 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
386 result->size = kInitialResult;
387 cmd.Init(kNewClientId,
388 kUniform2FakeLocation,
389 kSharedMemoryId,
390 kSharedMemoryOffset);
391 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
392 EXPECT_EQ(0U, result->size);
393 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
396 TEST_P(GLES2DecoderWithShaderTest, GetUniformfvBadLocationFails) {
397 GetUniformfv::Result* result =
398 static_cast<GetUniformfv::Result*>(shared_memory_address_);
399 result->size = 0;
400 GetUniformfv cmd;
401 // invalid location
402 cmd.Init(client_program_id_,
403 kInvalidUniformLocation,
404 kSharedMemoryId,
405 kSharedMemoryOffset);
406 EXPECT_CALL(*gl_, GetUniformfv(_, _, _)).Times(0);
407 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
408 EXPECT_EQ(0U, result->size);
409 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
412 TEST_P(GLES2DecoderWithShaderTest, GetUniformfvBadSharedMemoryFails) {
413 GetUniformfv cmd;
414 cmd.Init(client_program_id_,
415 kUniform2FakeLocation,
416 kInvalidSharedMemoryId,
417 kSharedMemoryOffset);
418 EXPECT_CALL(*gl_, GetUniformfv(_, _, _)).Times(0);
419 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
420 cmd.Init(client_program_id_,
421 kUniform2FakeLocation,
422 kSharedMemoryId,
423 kInvalidSharedMemoryOffset);
424 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
427 TEST_P(GLES2DecoderWithShaderTest, GetAttachedShadersSucceeds) {
428 GetAttachedShaders cmd;
429 typedef GetAttachedShaders::Result Result;
430 Result* result = static_cast<Result*>(shared_memory_address_);
431 result->size = 0;
432 EXPECT_CALL(*gl_, GetAttachedShaders(kServiceProgramId, 1, _, _)).WillOnce(
433 DoAll(SetArgPointee<2>(1), SetArgPointee<3>(kServiceShaderId)));
434 cmd.Init(client_program_id_,
435 shared_memory_id_,
436 shared_memory_offset_,
437 Result::ComputeSize(1));
438 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
439 EXPECT_EQ(1, result->GetNumResults());
440 EXPECT_EQ(client_shader_id_, result->GetData()[0]);
441 EXPECT_EQ(GL_NO_ERROR, GetGLError());
444 TEST_P(GLES2DecoderWithShaderTest, GetAttachedShadersResultNotInitFail) {
445 GetAttachedShaders cmd;
446 typedef GetAttachedShaders::Result Result;
447 Result* result = static_cast<Result*>(shared_memory_address_);
448 result->size = 1;
449 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _)).Times(0);
450 cmd.Init(client_program_id_,
451 shared_memory_id_,
452 shared_memory_offset_,
453 Result::ComputeSize(1));
454 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
457 TEST_P(GLES2DecoderWithShaderTest, GetAttachedShadersBadProgramFails) {
458 GetAttachedShaders cmd;
459 typedef GetAttachedShaders::Result Result;
460 Result* result = static_cast<Result*>(shared_memory_address_);
461 result->size = 0;
462 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _)).Times(0);
463 cmd.Init(kInvalidClientId,
464 shared_memory_id_,
465 shared_memory_offset_,
466 Result::ComputeSize(1));
467 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
468 EXPECT_EQ(0U, result->size);
469 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
472 TEST_P(GLES2DecoderWithShaderTest, GetAttachedShadersBadSharedMemoryFails) {
473 GetAttachedShaders cmd;
474 typedef GetAttachedShaders::Result Result;
475 cmd.Init(client_program_id_,
476 kInvalidSharedMemoryId,
477 shared_memory_offset_,
478 Result::ComputeSize(1));
479 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _)).Times(0);
480 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
481 cmd.Init(client_program_id_,
482 shared_memory_id_,
483 kInvalidSharedMemoryOffset,
484 Result::ComputeSize(1));
485 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
488 TEST_P(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatSucceeds) {
489 ScopedGLImplementationSetter gl_impl(::gfx::kGLImplementationEGLGLES2);
490 GetShaderPrecisionFormat cmd;
491 typedef GetShaderPrecisionFormat::Result Result;
492 Result* result = static_cast<Result*>(shared_memory_address_);
493 result->success = 0;
494 const GLint range[2] = {62, 62};
495 const GLint precision = 16;
496 EXPECT_CALL(*gl_, GetShaderPrecisionFormat(_, _, _, _))
497 .WillOnce(DoAll(SetArrayArgument<2>(range, range + 2),
498 SetArgPointee<3>(precision)))
499 .RetiresOnSaturation();
500 cmd.Init(GL_VERTEX_SHADER,
501 GL_HIGH_FLOAT,
502 shared_memory_id_,
503 shared_memory_offset_);
504 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
505 EXPECT_NE(0, result->success);
506 EXPECT_EQ(range[0], result->min_range);
507 EXPECT_EQ(range[1], result->max_range);
508 EXPECT_EQ(precision, result->precision);
509 EXPECT_EQ(GL_NO_ERROR, GetGLError());
512 TEST_P(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatResultNotInitFails) {
513 GetShaderPrecisionFormat cmd;
514 typedef GetShaderPrecisionFormat::Result Result;
515 Result* result = static_cast<Result*>(shared_memory_address_);
516 result->success = 1;
517 // NOTE: GL might not be called. There is no Desktop OpenGL equivalent
518 cmd.Init(GL_VERTEX_SHADER,
519 GL_HIGH_FLOAT,
520 shared_memory_id_,
521 shared_memory_offset_);
522 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
525 TEST_P(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatBadArgsFails) {
526 typedef GetShaderPrecisionFormat::Result Result;
527 Result* result = static_cast<Result*>(shared_memory_address_);
528 result->success = 0;
529 GetShaderPrecisionFormat cmd;
530 cmd.Init(
531 GL_TEXTURE_2D, GL_HIGH_FLOAT, shared_memory_id_, shared_memory_offset_);
532 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
533 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
534 result->success = 0;
535 cmd.Init(GL_VERTEX_SHADER,
536 GL_TEXTURE_2D,
537 shared_memory_id_,
538 shared_memory_offset_);
539 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
540 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
543 TEST_P(GLES2DecoderWithShaderTest,
544 GetShaderPrecisionFormatBadSharedMemoryFails) {
545 GetShaderPrecisionFormat cmd;
546 cmd.Init(GL_VERTEX_SHADER,
547 GL_HIGH_FLOAT,
548 kInvalidSharedMemoryId,
549 shared_memory_offset_);
550 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
551 cmd.Init(GL_VERTEX_SHADER,
552 GL_TEXTURE_2D,
553 shared_memory_id_,
554 kInvalidSharedMemoryOffset);
555 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
558 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformSucceeds) {
559 const GLuint kUniformIndex = 1;
560 const uint32 kBucketId = 123;
561 GetActiveUniform cmd;
562 typedef GetActiveUniform::Result Result;
563 Result* result = static_cast<Result*>(shared_memory_address_);
564 result->success = 0;
565 cmd.Init(client_program_id_,
566 kUniformIndex,
567 kBucketId,
568 shared_memory_id_,
569 shared_memory_offset_);
570 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
571 EXPECT_NE(0, result->success);
572 EXPECT_EQ(kUniform2Size, result->size);
573 EXPECT_EQ(kUniform2Type, result->type);
574 EXPECT_EQ(GL_NO_ERROR, GetGLError());
575 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
576 ASSERT_TRUE(bucket != NULL);
577 EXPECT_EQ(
579 memcmp(
580 bucket->GetData(0, bucket->size()), kUniform2Name, bucket->size()));
583 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformResultNotInitFails) {
584 const GLuint kUniformIndex = 1;
585 const uint32 kBucketId = 123;
586 GetActiveUniform cmd;
587 typedef GetActiveUniform::Result Result;
588 Result* result = static_cast<Result*>(shared_memory_address_);
589 result->success = 1;
590 cmd.Init(client_program_id_,
591 kUniformIndex,
592 kBucketId,
593 shared_memory_id_,
594 shared_memory_offset_);
595 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
598 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBadProgramFails) {
599 const GLuint kUniformIndex = 1;
600 const uint32 kBucketId = 123;
601 GetActiveUniform cmd;
602 typedef GetActiveUniform::Result Result;
603 Result* result = static_cast<Result*>(shared_memory_address_);
604 result->success = 0;
605 cmd.Init(kInvalidClientId,
606 kUniformIndex,
607 kBucketId,
608 shared_memory_id_,
609 shared_memory_offset_);
610 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
611 EXPECT_EQ(0, result->success);
612 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
613 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS
614 result->success = 0;
615 cmd.Init(client_shader_id_,
616 kUniformIndex,
617 kBucketId,
618 shared_memory_id_,
619 shared_memory_offset_);
620 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
621 EXPECT_EQ(0, result->success);
622 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
623 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS
626 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBadIndexFails) {
627 const uint32 kBucketId = 123;
628 GetActiveUniform cmd;
629 typedef GetActiveUniform::Result Result;
630 Result* result = static_cast<Result*>(shared_memory_address_);
631 result->success = 0;
632 cmd.Init(client_program_id_,
633 kBadUniformIndex,
634 kBucketId,
635 shared_memory_id_,
636 shared_memory_offset_);
637 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
638 EXPECT_EQ(0, result->success);
639 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
642 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBadSharedMemoryFails) {
643 const GLuint kUniformIndex = 1;
644 const uint32 kBucketId = 123;
645 GetActiveUniform cmd;
646 cmd.Init(client_program_id_,
647 kUniformIndex,
648 kBucketId,
649 kInvalidSharedMemoryId,
650 shared_memory_offset_);
651 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
652 cmd.Init(client_program_id_,
653 kUniformIndex,
654 kBucketId,
655 shared_memory_id_,
656 kInvalidSharedMemoryOffset);
657 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
660 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBlockNameSucceeds) {
661 const uint32 kBucketId = 123;
662 GetActiveUniformBlockName cmd;
663 typedef GetActiveUniformBlockName::Result Result;
664 Result* result = static_cast<Result*>(shared_memory_address_);
665 *result = 0;
666 cmd.Init(client_program_id_,
668 kBucketId,
669 shared_memory_id_,
670 shared_memory_offset_);
671 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
672 .WillOnce(SetArgPointee<2>(GL_TRUE))
673 .RetiresOnSaturation();
674 const char kName[] = "HolyCow";
675 const GLsizei kMaxLength = strlen(kName) + 1;
676 EXPECT_CALL(*gl_,
677 GetProgramiv(kServiceProgramId,
678 GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, _))
679 .WillOnce(SetArgPointee<2>(kMaxLength))
680 .RetiresOnSaturation();
681 EXPECT_CALL(*gl_,
682 GetActiveUniformBlockName(kServiceProgramId, 0, _, _, _))
683 .WillOnce(DoAll(SetArgPointee<3>(strlen(kName)),
684 SetArrayArgument<4>(kName, kName + strlen(kName) + 1)))
685 .RetiresOnSaturation();
686 decoder_->set_unsafe_es3_apis_enabled(true);
687 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
688 EXPECT_NE(0, *result);
689 EXPECT_EQ(GL_NO_ERROR, GetGLError());
690 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
691 ASSERT_TRUE(bucket != NULL);
692 EXPECT_EQ(0,
693 memcmp(bucket->GetData(0, bucket->size()), kName, bucket->size()));
694 decoder_->set_unsafe_es3_apis_enabled(false);
695 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
698 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBlockNameUnlinkedProgram) {
699 const uint32 kBucketId = 123;
700 GetActiveUniformBlockName cmd;
701 typedef GetActiveUniformBlockName::Result Result;
702 Result* result = static_cast<Result*>(shared_memory_address_);
703 *result = 0;
704 cmd.Init(client_program_id_,
706 kBucketId,
707 shared_memory_id_,
708 shared_memory_offset_);
709 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
710 .WillOnce(SetArgPointee<2>(GL_FALSE))
711 .RetiresOnSaturation();
712 decoder_->set_unsafe_es3_apis_enabled(true);
713 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
714 EXPECT_EQ(0, *result);
715 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
718 TEST_P(GLES2DecoderWithShaderTest,
719 GetActiveUniformBlockNameResultNotInitFails) {
720 const uint32 kBucketId = 123;
721 GetActiveUniformBlockName cmd;
722 typedef GetActiveUniformBlockName::Result Result;
723 Result* result = static_cast<Result*>(shared_memory_address_);
724 *result = 1;
725 cmd.Init(client_program_id_,
727 kBucketId,
728 shared_memory_id_,
729 shared_memory_offset_);
730 decoder_->set_unsafe_es3_apis_enabled(true);
731 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
734 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBlockNameBadProgramFails) {
735 const uint32 kBucketId = 123;
736 GetActiveUniformBlockName cmd;
737 typedef GetActiveUniformBlockName::Result Result;
738 Result* result = static_cast<Result*>(shared_memory_address_);
739 *result = 0;
740 cmd.Init(kInvalidClientId,
742 kBucketId,
743 shared_memory_id_,
744 shared_memory_offset_);
745 decoder_->set_unsafe_es3_apis_enabled(true);
746 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
747 EXPECT_EQ(0, *result);
748 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
751 TEST_P(GLES2DecoderWithShaderTest,
752 GetActiveUniformBlockNameBadSharedMemoryFails) {
753 const uint32 kBucketId = 123;
754 GetActiveUniformBlockName cmd;
755 decoder_->set_unsafe_es3_apis_enabled(true);
756 cmd.Init(client_program_id_,
758 kBucketId,
759 kInvalidSharedMemoryId,
760 shared_memory_offset_);
761 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
762 cmd.Init(client_program_id_,
764 kBucketId,
765 shared_memory_id_,
766 kInvalidSharedMemoryOffset);
767 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
770 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBlockivSucceeds) {
771 GetActiveUniformBlockiv cmd;
772 typedef GetActiveUniformBlockiv::Result Result;
773 Result* result = static_cast<Result*>(shared_memory_address_);
774 GLenum kPname[] {
775 GL_UNIFORM_BLOCK_BINDING,
776 GL_UNIFORM_BLOCK_DATA_SIZE,
777 GL_UNIFORM_BLOCK_NAME_LENGTH,
778 GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS,
779 GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES,
780 GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER,
781 GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER,
783 for (size_t ii = 0; ii < arraysize(kPname); ++ii) {
784 result->SetNumResults(0);
785 cmd.Init(client_program_id_,
787 kPname[ii],
788 shared_memory_id_,
789 shared_memory_offset_);
790 EXPECT_CALL(*gl_, GetError())
791 .WillOnce(Return(GL_NO_ERROR))
792 .WillOnce(Return(GL_NO_ERROR))
793 .RetiresOnSaturation();
794 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
795 .WillOnce(SetArgPointee<2>(GL_TRUE))
796 .RetiresOnSaturation();
797 if (kPname[ii] == GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) {
798 EXPECT_CALL(*gl_, GetError())
799 .WillOnce(Return(GL_NO_ERROR))
800 .RetiresOnSaturation();
801 EXPECT_CALL(*gl_,
802 GetActiveUniformBlockiv(kServiceProgramId, 0,
803 GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, _))
804 .WillOnce(SetArgPointee<3>(1))
805 .RetiresOnSaturation();
807 EXPECT_CALL(*gl_,
808 GetActiveUniformBlockiv(
809 kServiceProgramId, 0, kPname[ii], _))
810 .WillOnce(SetArgPointee<3>(1976))
811 .RetiresOnSaturation();
812 decoder_->set_unsafe_es3_apis_enabled(true);
813 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
814 EXPECT_EQ(1, result->GetNumResults());
815 EXPECT_EQ(GL_NO_ERROR, GetGLError());
816 EXPECT_EQ(1976, result->GetData()[0]);
817 decoder_->set_unsafe_es3_apis_enabled(false);
818 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
822 TEST_P(GLES2DecoderWithShaderTest,
823 GetActiveUniformBlockivSucceedsZeroUniforms) {
824 GetActiveUniformBlockiv cmd;
825 typedef GetActiveUniformBlockiv::Result Result;
826 Result* result = static_cast<Result*>(shared_memory_address_);
827 result->SetNumResults(0);
828 cmd.Init(client_program_id_,
830 GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES,
831 shared_memory_id_,
832 shared_memory_offset_);
833 EXPECT_CALL(*gl_, GetError())
834 .WillOnce(Return(GL_NO_ERROR))
835 .WillOnce(Return(GL_NO_ERROR))
836 .WillOnce(Return(GL_NO_ERROR))
837 .RetiresOnSaturation();
838 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
839 .WillOnce(SetArgPointee<2>(GL_TRUE))
840 .RetiresOnSaturation();
841 EXPECT_CALL(*gl_,
842 GetActiveUniformBlockiv(
843 kServiceProgramId, 0, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, _))
844 .WillOnce(SetArgPointee<3>(0))
845 .RetiresOnSaturation();
846 EXPECT_CALL(*gl_,
847 GetActiveUniformBlockiv(kServiceProgramId, 0,
848 GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, _))
849 .Times(1)
850 .RetiresOnSaturation();
851 decoder_->set_unsafe_es3_apis_enabled(true);
852 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
853 EXPECT_EQ(0, result->GetNumResults());
854 EXPECT_EQ(GL_NO_ERROR, GetGLError());
857 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBlockivUnlinkedProgram) {
858 GetActiveUniformBlockiv cmd;
859 typedef GetActiveUniformBlockiv::Result Result;
860 Result* result = static_cast<Result*>(shared_memory_address_);
861 result->SetNumResults(0);
862 cmd.Init(client_program_id_,
864 GL_UNIFORM_BLOCK_BINDING,
865 shared_memory_id_,
866 shared_memory_offset_);
867 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
868 .WillOnce(SetArgPointee<2>(GL_FALSE))
869 .RetiresOnSaturation();
870 decoder_->set_unsafe_es3_apis_enabled(true);
871 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
872 EXPECT_EQ(0, result->GetNumResults());
873 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
876 TEST_P(GLES2DecoderWithShaderTest,
877 GetActiveUniformBlockivResultNotInitFails) {
878 GetActiveUniformBlockiv cmd;
879 typedef GetActiveUniformBlockiv::Result Result;
880 Result* result = static_cast<Result*>(shared_memory_address_);
881 result->SetNumResults(1); // Should be initialized to 0.
882 cmd.Init(client_program_id_,
884 GL_UNIFORM_BLOCK_BINDING,
885 shared_memory_id_,
886 shared_memory_offset_);
887 decoder_->set_unsafe_es3_apis_enabled(true);
888 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
889 .WillOnce(SetArgPointee<2>(GL_TRUE))
890 .RetiresOnSaturation();
891 EXPECT_CALL(*gl_, GetError())
892 .WillOnce(Return(GL_NO_ERROR))
893 .RetiresOnSaturation();
894 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
897 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBlockivBadProgramFails) {
898 GetActiveUniformBlockiv cmd;
899 typedef GetActiveUniformBlockiv::Result Result;
900 Result* result = static_cast<Result*>(shared_memory_address_);
901 result->SetNumResults(0);
902 cmd.Init(kInvalidClientId,
904 GL_UNIFORM_BLOCK_BINDING,
905 shared_memory_id_,
906 shared_memory_offset_);
907 decoder_->set_unsafe_es3_apis_enabled(true);
908 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
909 EXPECT_EQ(0, result->GetNumResults());
910 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
913 TEST_P(GLES2DecoderWithShaderTest,
914 GetActiveUniformBlockivBadSharedMemoryFails) {
915 GetActiveUniformBlockiv cmd;
916 decoder_->set_unsafe_es3_apis_enabled(true);
917 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
918 .WillOnce(SetArgPointee<2>(GL_TRUE))
919 .WillOnce(SetArgPointee<2>(GL_TRUE))
920 .RetiresOnSaturation();
921 EXPECT_CALL(*gl_, GetError())
922 .WillOnce(Return(GL_NO_ERROR))
923 .WillOnce(Return(GL_NO_ERROR))
924 .RetiresOnSaturation();
925 cmd.Init(client_program_id_,
927 GL_UNIFORM_BLOCK_BINDING,
928 kInvalidSharedMemoryId,
929 shared_memory_offset_);
930 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
931 cmd.Init(client_program_id_,
933 GL_UNIFORM_BLOCK_BINDING,
934 shared_memory_id_,
935 kInvalidSharedMemoryOffset);
936 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
939 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribSucceeds) {
940 const GLuint kAttribIndex = 1;
941 const uint32 kBucketId = 123;
942 GetActiveAttrib cmd;
943 typedef GetActiveAttrib::Result Result;
944 Result* result = static_cast<Result*>(shared_memory_address_);
945 result->success = 0;
946 cmd.Init(client_program_id_,
947 kAttribIndex,
948 kBucketId,
949 shared_memory_id_,
950 shared_memory_offset_);
951 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
952 EXPECT_NE(0, result->success);
953 EXPECT_EQ(kAttrib2Size, result->size);
954 EXPECT_EQ(kAttrib2Type, result->type);
955 EXPECT_EQ(GL_NO_ERROR, GetGLError());
956 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
957 ASSERT_TRUE(bucket != NULL);
958 EXPECT_EQ(
960 memcmp(bucket->GetData(0, bucket->size()), kAttrib2Name, bucket->size()));
963 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribResultNotInitFails) {
964 const GLuint kAttribIndex = 1;
965 const uint32 kBucketId = 123;
966 GetActiveAttrib cmd;
967 typedef GetActiveAttrib::Result Result;
968 Result* result = static_cast<Result*>(shared_memory_address_);
969 result->success = 1;
970 cmd.Init(client_program_id_,
971 kAttribIndex,
972 kBucketId,
973 shared_memory_id_,
974 shared_memory_offset_);
975 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
978 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribBadProgramFails) {
979 const GLuint kAttribIndex = 1;
980 const uint32 kBucketId = 123;
981 GetActiveAttrib cmd;
982 typedef GetActiveAttrib::Result Result;
983 Result* result = static_cast<Result*>(shared_memory_address_);
984 result->success = 0;
985 cmd.Init(kInvalidClientId,
986 kAttribIndex,
987 kBucketId,
988 shared_memory_id_,
989 shared_memory_offset_);
990 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
991 EXPECT_EQ(0, result->success);
992 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
993 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS
994 result->success = 0;
995 cmd.Init(client_shader_id_,
996 kAttribIndex,
997 kBucketId,
998 shared_memory_id_,
999 shared_memory_offset_);
1000 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1001 EXPECT_EQ(0, result->success);
1002 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1003 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS
1006 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribBadIndexFails) {
1007 const uint32 kBucketId = 123;
1008 GetActiveAttrib cmd;
1009 typedef GetActiveAttrib::Result Result;
1010 Result* result = static_cast<Result*>(shared_memory_address_);
1011 result->success = 0;
1012 cmd.Init(client_program_id_,
1013 kBadAttribIndex,
1014 kBucketId,
1015 shared_memory_id_,
1016 shared_memory_offset_);
1017 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1018 EXPECT_EQ(0, result->success);
1019 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1022 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribBadSharedMemoryFails) {
1023 const GLuint kAttribIndex = 1;
1024 const uint32 kBucketId = 123;
1025 GetActiveAttrib cmd;
1026 cmd.Init(client_program_id_,
1027 kAttribIndex,
1028 kBucketId,
1029 kInvalidSharedMemoryId,
1030 shared_memory_offset_);
1031 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1032 cmd.Init(client_program_id_,
1033 kAttribIndex,
1034 kBucketId,
1035 shared_memory_id_,
1036 kInvalidSharedMemoryOffset);
1037 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1040 TEST_P(GLES2DecoderWithShaderTest, GetUniformIndicesSucceeds) {
1041 const uint32 kBucketId = 123;
1042 const char kName0[] = "Cow";
1043 const char kName1[] = "Chicken";
1044 const char* kNames[] = { kName0, kName1 };
1045 const size_t kCount = arraysize(kNames);
1046 const char kValidStrEnd = 0;
1047 const GLuint kIndices[] = { 1, 2 };
1048 SetBucketAsCStrings(kBucketId, kCount, kNames, kCount, kValidStrEnd);
1049 GetUniformIndices::Result* result =
1050 static_cast<GetUniformIndices::Result*>(shared_memory_address_);
1051 GetUniformIndices cmd;
1052 cmd.Init(client_program_id_,
1053 kBucketId,
1054 kSharedMemoryId,
1055 kSharedMemoryOffset);
1056 EXPECT_CALL(*gl_, GetUniformIndices(kServiceProgramId, kCount, _, _))
1057 .WillOnce(SetArrayArgument<3>(kIndices, kIndices + kCount))
1058 .RetiresOnSaturation();
1059 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
1060 .WillOnce(SetArgPointee<2>(GL_TRUE))
1061 .RetiresOnSaturation();
1062 EXPECT_CALL(*gl_, GetError())
1063 .WillOnce(Return(GL_NO_ERROR))
1064 .WillOnce(Return(GL_NO_ERROR))
1065 .RetiresOnSaturation();
1066 decoder_->set_unsafe_es3_apis_enabled(true);
1067 result->size = 0;
1068 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1069 EXPECT_EQ(kCount, static_cast<size_t>(result->GetNumResults()));
1070 for (size_t ii = 0; ii < kCount; ++ii) {
1071 EXPECT_EQ(kIndices[ii], result->GetData()[ii]);
1073 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1074 decoder_->set_unsafe_es3_apis_enabled(false);
1075 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
1078 TEST_P(GLES2DecoderWithShaderTest, GetUniformIndicesBadProgramFails) {
1079 const uint32 kBucketId = 123;
1080 const char kName0[] = "Cow";
1081 const char kName1[] = "Chicken";
1082 const char* kNames[] = { kName0, kName1 };
1083 const size_t kCount = arraysize(kNames);
1084 const char kValidStrEnd = 0;
1085 SetBucketAsCStrings(kBucketId, kCount, kNames, kCount, kValidStrEnd);
1086 GetUniformIndices::Result* result =
1087 static_cast<GetUniformIndices::Result*>(shared_memory_address_);
1088 decoder_->set_unsafe_es3_apis_enabled(true);
1089 GetUniformIndices cmd;
1090 // None-existant program
1091 cmd.Init(kInvalidClientId,
1092 kBucketId,
1093 kSharedMemoryId,
1094 kSharedMemoryOffset);
1095 result->size = 0;
1096 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1097 EXPECT_EQ(0, result->GetNumResults());
1098 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1099 // Unlinked program.
1100 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
1101 .WillOnce(SetArgPointee<2>(GL_FALSE))
1102 .RetiresOnSaturation();
1103 cmd.Init(client_program_id_,
1104 kBucketId,
1105 kSharedMemoryId,
1106 kSharedMemoryOffset);
1107 result->size = 0;
1108 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1109 EXPECT_EQ(0, result->GetNumResults());
1110 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1113 TEST_P(GLES2DecoderWithShaderTest, GetUniformIndicesBadParamsFails) {
1114 const uint32 kBucketId = 123;
1115 const char kName0[] = "Cow";
1116 const char kName1[] = "Chicken";
1117 const char* kNames[] = { kName0, kName1 };
1118 const size_t kCount = arraysize(kNames);
1119 const char kValidStrEnd = 0;
1120 const GLuint kIndices[] = { 1, 2 };
1121 SetBucketAsCStrings(kBucketId, kCount, kNames, kCount, kValidStrEnd);
1122 GetUniformIndices::Result* result =
1123 static_cast<GetUniformIndices::Result*>(shared_memory_address_);
1124 GetUniformIndices cmd;
1125 cmd.Init(client_program_id_,
1126 kBucketId,
1127 kSharedMemoryId,
1128 kSharedMemoryOffset);
1129 EXPECT_CALL(*gl_, GetUniformIndices(kServiceProgramId, kCount, _, _))
1130 .WillOnce(SetArrayArgument<3>(kIndices, kIndices + kCount))
1131 .RetiresOnSaturation();
1132 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
1133 .WillOnce(SetArgPointee<2>(GL_TRUE))
1134 .RetiresOnSaturation();
1135 EXPECT_CALL(*gl_, GetError())
1136 .WillOnce(Return(GL_NO_ERROR))
1137 .WillOnce(Return(GL_INVALID_VALUE))
1138 .RetiresOnSaturation();
1139 decoder_->set_unsafe_es3_apis_enabled(true);
1140 result->size = 0;
1141 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1142 EXPECT_EQ(0, result->GetNumResults());
1143 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1146 TEST_P(GLES2DecoderWithShaderTest, GetUniformIndicesResultNotInitFails) {
1147 const uint32 kBucketId = 123;
1148 const char kName0[] = "Cow";
1149 const char kName1[] = "Chicken";
1150 const char* kNames[] = { kName0, kName1 };
1151 const size_t kCount = arraysize(kNames);
1152 const char kValidStrEnd = 0;
1153 SetBucketAsCStrings(kBucketId, kCount, kNames, kCount, kValidStrEnd);
1154 GetUniformIndices::Result* result =
1155 static_cast<GetUniformIndices::Result*>(shared_memory_address_);
1156 decoder_->set_unsafe_es3_apis_enabled(true);
1157 GetUniformIndices cmd;
1158 result->size = 1976; // Any value other than 0.
1159 cmd.Init(kInvalidClientId,
1160 kBucketId,
1161 kSharedMemoryId,
1162 kSharedMemoryOffset);
1163 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1166 TEST_P(GLES2DecoderWithShaderTest, GetUniformIndicesBadSharedMemoryFails) {
1167 const uint32 kBucketId = 123;
1168 const char kName0[] = "Cow";
1169 const char kName1[] = "Chicken";
1170 const char* kNames[] = { kName0, kName1 };
1171 const size_t kCount = arraysize(kNames);
1172 const char kValidStrEnd = 0;
1173 SetBucketAsCStrings(kBucketId, kCount, kNames, kCount, kValidStrEnd);
1174 GetUniformIndices::Result* result =
1175 static_cast<GetUniformIndices::Result*>(shared_memory_address_);
1176 decoder_->set_unsafe_es3_apis_enabled(true);
1177 GetUniformIndices cmd;
1178 cmd.Init(client_program_id_,
1179 kBucketId,
1180 kInvalidSharedMemoryId,
1181 kSharedMemoryOffset);
1182 result->size = 0;
1183 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1184 cmd.Init(client_program_id_,
1185 kBucketId,
1186 kSharedMemoryId,
1187 kInvalidSharedMemoryOffset);
1188 result->size = 0;
1189 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1192 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformsivSucceeds) {
1193 const uint32 kBucketId = 123;
1194 const GLuint kIndices[] = { 1, 2 };
1195 const GLint kResults[] = { 1976, 321 };
1196 const size_t kCount = arraysize(kIndices);
1197 SetBucketData(kBucketId, kIndices, sizeof(GLuint) * kCount);
1198 GetActiveUniformsiv::Result* result =
1199 static_cast<GetActiveUniformsiv::Result*>(shared_memory_address_);
1200 GetActiveUniformsiv cmd;
1201 cmd.Init(client_program_id_,
1202 kBucketId,
1203 GL_UNIFORM_TYPE,
1204 kSharedMemoryId,
1205 kSharedMemoryOffset);
1206 EXPECT_CALL(*gl_,
1207 GetActiveUniformsiv(
1208 kServiceProgramId, kCount, _, GL_UNIFORM_TYPE, _))
1209 .WillOnce(SetArrayArgument<4>(kResults, kResults + kCount))
1210 .RetiresOnSaturation();
1211 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
1212 .WillOnce(SetArgPointee<2>(GL_TRUE))
1213 .RetiresOnSaturation();
1214 EXPECT_CALL(*gl_, GetError())
1215 .WillOnce(Return(GL_NO_ERROR))
1216 .WillOnce(Return(GL_NO_ERROR))
1217 .RetiresOnSaturation();
1218 decoder_->set_unsafe_es3_apis_enabled(true);
1219 result->size = 0;
1220 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1221 EXPECT_EQ(kCount, static_cast<size_t>(result->GetNumResults()));
1222 for (size_t ii = 0; ii < kCount; ++ii) {
1223 EXPECT_EQ(kResults[ii], result->GetData()[ii]);
1225 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1226 decoder_->set_unsafe_es3_apis_enabled(false);
1227 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
1230 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformsivBadProgramFails) {
1231 const uint32 kBucketId = 123;
1232 const GLuint kIndices[] = { 1, 2 };
1233 const size_t kCount = arraysize(kIndices);
1234 SetBucketData(kBucketId, kIndices, sizeof(GLuint) * kCount);
1235 GetActiveUniformsiv::Result* result =
1236 static_cast<GetActiveUniformsiv::Result*>(shared_memory_address_);
1237 decoder_->set_unsafe_es3_apis_enabled(true);
1238 GetActiveUniformsiv cmd;
1239 // None-existant program
1240 cmd.Init(kInvalidClientId,
1241 kBucketId,
1242 GL_UNIFORM_TYPE,
1243 kSharedMemoryId,
1244 kSharedMemoryOffset);
1245 result->size = 0;
1246 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1247 EXPECT_EQ(0, result->GetNumResults());
1248 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1249 // Unlinked program.
1250 cmd.Init(client_program_id_,
1251 kBucketId,
1252 GL_UNIFORM_TYPE,
1253 kSharedMemoryId,
1254 kSharedMemoryOffset);
1255 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
1256 .WillOnce(SetArgPointee<2>(GL_FALSE))
1257 .RetiresOnSaturation();
1258 result->size = 0;
1259 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1260 EXPECT_EQ(0, result->GetNumResults());
1261 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1264 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformsivBadParamsFails) {
1265 const uint32 kBucketId = 123;
1266 const GLuint kIndices[] = { 1, 2 };
1267 const GLint kResults[] = { 1976, 321 };
1268 const size_t kCount = arraysize(kIndices);
1269 SetBucketData(kBucketId, kIndices, sizeof(GLuint) * kCount);
1270 GetActiveUniformsiv::Result* result =
1271 static_cast<GetActiveUniformsiv::Result*>(shared_memory_address_);
1272 GetActiveUniformsiv cmd;
1273 cmd.Init(client_program_id_,
1274 kBucketId,
1275 GL_UNIFORM_TYPE,
1276 kSharedMemoryId,
1277 kSharedMemoryOffset);
1278 EXPECT_CALL(*gl_,
1279 GetActiveUniformsiv(
1280 kServiceProgramId, kCount, _, GL_UNIFORM_TYPE, _))
1281 .WillOnce(SetArrayArgument<4>(kResults, kResults + kCount))
1282 .RetiresOnSaturation();
1283 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
1284 .WillOnce(SetArgPointee<2>(GL_TRUE))
1285 .RetiresOnSaturation();
1286 EXPECT_CALL(*gl_, GetError())
1287 .WillOnce(Return(GL_NO_ERROR))
1288 .WillOnce(Return(GL_INVALID_VALUE))
1289 .RetiresOnSaturation();
1290 decoder_->set_unsafe_es3_apis_enabled(true);
1291 result->size = 0;
1292 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1293 EXPECT_EQ(0, result->GetNumResults());
1294 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1297 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformsivResultNotInitFails) {
1298 const uint32 kBucketId = 123;
1299 const GLuint kIndices[] = { 1, 2 };
1300 const size_t kCount = arraysize(kIndices);
1301 SetBucketData(kBucketId, kIndices, sizeof(GLuint) * kCount);
1302 GetActiveUniformsiv::Result* result =
1303 static_cast<GetActiveUniformsiv::Result*>(shared_memory_address_);
1304 GetActiveUniformsiv cmd;
1305 cmd.Init(client_program_id_,
1306 kBucketId,
1307 GL_UNIFORM_TYPE,
1308 kSharedMemoryId,
1309 kSharedMemoryOffset);
1310 decoder_->set_unsafe_es3_apis_enabled(true);
1311 result->size = 1976; // Any value other than 0.
1312 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1315 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformsivBadSharedMemoryFails) {
1316 const uint32 kBucketId = 123;
1317 const GLuint kIndices[] = { 1, 2 };
1318 const size_t kCount = arraysize(kIndices);
1319 SetBucketData(kBucketId, kIndices, sizeof(GLuint) * kCount);
1320 GetActiveUniformsiv::Result* result =
1321 static_cast<GetActiveUniformsiv::Result*>(shared_memory_address_);
1322 GetActiveUniformsiv cmd;
1323 decoder_->set_unsafe_es3_apis_enabled(true);
1324 result->size = 0;
1325 cmd.Init(client_program_id_,
1326 kBucketId,
1327 GL_UNIFORM_TYPE,
1328 kInvalidSharedMemoryId,
1329 kSharedMemoryOffset);
1330 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1331 result->size = 0;
1332 cmd.Init(client_program_id_,
1333 kBucketId,
1334 GL_UNIFORM_TYPE,
1335 kSharedMemoryId,
1336 kInvalidSharedMemoryOffset);
1337 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1340 TEST_P(GLES2DecoderWithShaderTest, GetShaderInfoLogValidArgs) {
1341 const char* kInfo = "hello";
1342 const uint32 kBucketId = 123;
1343 CompileShader compile_cmd;
1344 GetShaderInfoLog cmd;
1345 EXPECT_CALL(*gl_, ShaderSource(kServiceShaderId, 1, _, _));
1346 EXPECT_CALL(*gl_, CompileShader(kServiceShaderId));
1347 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_COMPILE_STATUS, _))
1348 .WillOnce(SetArgPointee<2>(GL_FALSE))
1349 .RetiresOnSaturation();
1350 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_INFO_LOG_LENGTH, _))
1351 .WillOnce(SetArgPointee<2>(strlen(kInfo) + 1))
1352 .RetiresOnSaturation();
1353 EXPECT_CALL(*gl_, GetShaderInfoLog(kServiceShaderId, strlen(kInfo) + 1, _, _))
1354 .WillOnce(DoAll(SetArgPointee<2>(strlen(kInfo)),
1355 SetArrayArgument<3>(kInfo, kInfo + strlen(kInfo) + 1)));
1356 compile_cmd.Init(client_shader_id_);
1357 cmd.Init(client_shader_id_, kBucketId);
1358 EXPECT_EQ(error::kNoError, ExecuteCmd(compile_cmd));
1359 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1360 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
1361 ASSERT_TRUE(bucket != NULL);
1362 EXPECT_EQ(strlen(kInfo) + 1, bucket->size());
1363 EXPECT_EQ(0,
1364 memcmp(bucket->GetData(0, bucket->size()), kInfo, bucket->size()));
1365 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1368 TEST_P(GLES2DecoderWithShaderTest, GetShaderInfoLogInvalidArgs) {
1369 const uint32 kBucketId = 123;
1370 GetShaderInfoLog cmd;
1371 cmd.Init(kInvalidClientId, kBucketId);
1372 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1373 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1376 TEST_P(GLES2DecoderWithShaderTest, GetTransformFeedbackVaryingSucceeds) {
1377 const GLuint kIndex = 1;
1378 const uint32 kBucketId = 123;
1379 const char kName[] = "HolyCow";
1380 const GLsizei kBufferSize = static_cast<GLsizei>(strlen(kName) + 1);
1381 const GLsizei kSize = 2;
1382 const GLenum kType = GL_FLOAT_VEC2;
1383 GetTransformFeedbackVarying cmd;
1384 typedef GetTransformFeedbackVarying::Result Result;
1385 Result* result = static_cast<Result*>(shared_memory_address_);
1386 result->success = 0;
1387 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
1388 .WillOnce(SetArgPointee<2>(GL_TRUE))
1389 .RetiresOnSaturation();
1390 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId,
1391 GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, _))
1392 .WillOnce(SetArgPointee<2>(kBufferSize))
1393 .RetiresOnSaturation();
1394 EXPECT_CALL(*gl_, GetError())
1395 .WillOnce(Return(GL_NO_ERROR))
1396 .WillOnce(Return(GL_NO_ERROR))
1397 .RetiresOnSaturation();
1398 EXPECT_CALL(*gl_,
1399 GetTransformFeedbackVarying(
1400 kServiceProgramId, kIndex, _, _, _, _, _))
1401 .WillOnce(DoAll(SetArgPointee<3>(kBufferSize - 1),
1402 SetArgPointee<4>(kSize),
1403 SetArgPointee<5>(kType),
1404 SetArrayArgument<6>(kName, kName + kBufferSize)))
1405 .RetiresOnSaturation();
1406 cmd.Init(client_program_id_,
1407 kIndex,
1408 kBucketId,
1409 shared_memory_id_,
1410 shared_memory_offset_);
1411 decoder_->set_unsafe_es3_apis_enabled(true);
1412 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1413 EXPECT_NE(0, result->success);
1414 EXPECT_EQ(kSize, static_cast<GLsizei>(result->size));
1415 EXPECT_EQ(kType, static_cast<GLenum>(result->type));
1416 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1417 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
1418 ASSERT_TRUE(bucket != NULL);
1419 EXPECT_EQ(
1420 0, memcmp(bucket->GetData(0, bucket->size()), kName, bucket->size()));
1421 decoder_->set_unsafe_es3_apis_enabled(false);
1422 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
1425 TEST_P(GLES2DecoderWithShaderTest, GetTransformFeedbackVaryingNotInitFails) {
1426 const GLuint kIndex = 1;
1427 const uint32 kBucketId = 123;
1428 GetTransformFeedbackVarying cmd;
1429 typedef GetTransformFeedbackVarying::Result Result;
1430 Result* result = static_cast<Result*>(shared_memory_address_);
1431 result->success = 1;
1432 cmd.Init(client_program_id_,
1433 kIndex,
1434 kBucketId,
1435 shared_memory_id_,
1436 shared_memory_offset_);
1437 decoder_->set_unsafe_es3_apis_enabled(true);
1438 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1441 TEST_P(GLES2DecoderWithShaderTest, GetTransformFeedbackVaryingBadProgramFails) {
1442 const GLuint kIndex = 1;
1443 const uint32 kBucketId = 123;
1444 GetTransformFeedbackVarying cmd;
1445 typedef GetTransformFeedbackVarying::Result Result;
1446 Result* result = static_cast<Result*>(shared_memory_address_);
1447 result->success = 0;
1448 cmd.Init(kInvalidClientId,
1449 kIndex,
1450 kBucketId,
1451 shared_memory_id_,
1452 shared_memory_offset_);
1453 decoder_->set_unsafe_es3_apis_enabled(true);
1454 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1455 EXPECT_EQ(0, result->success);
1456 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1459 TEST_P(GLES2DecoderWithShaderTest, GetTransformFeedbackVaryingBadParamsFails) {
1460 const GLuint kIndex = 1;
1461 const uint32 kBucketId = 123;
1462 const GLsizei kBufferSize = 10;
1463 GetTransformFeedbackVarying cmd;
1464 typedef GetTransformFeedbackVarying::Result Result;
1465 Result* result = static_cast<Result*>(shared_memory_address_);
1466 result->success = 0;
1467 cmd.Init(client_program_id_,
1468 kIndex,
1469 kBucketId,
1470 shared_memory_id_,
1471 shared_memory_offset_);
1472 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
1473 .WillOnce(SetArgPointee<2>(GL_TRUE))
1474 .RetiresOnSaturation();
1475 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId,
1476 GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, _))
1477 .WillOnce(SetArgPointee<2>(kBufferSize))
1478 .RetiresOnSaturation();
1479 EXPECT_CALL(*gl_, GetError())
1480 .WillOnce(Return(GL_NO_ERROR))
1481 .WillOnce(Return(GL_INVALID_VALUE))
1482 .RetiresOnSaturation();
1483 EXPECT_CALL(*gl_,
1484 GetTransformFeedbackVarying(
1485 kServiceProgramId, kIndex, _, _, _, _, _))
1486 .Times(1)
1487 .RetiresOnSaturation();
1488 decoder_->set_unsafe_es3_apis_enabled(true);
1489 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1490 EXPECT_EQ(0, result->success);
1491 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1494 TEST_P(GLES2DecoderWithShaderTest,
1495 GetTransformFeedbackVaryingBadSharedMemoryFails) {
1496 const GLuint kIndex = 1;
1497 const uint32 kBucketId = 123;
1498 GetTransformFeedbackVarying cmd;
1499 typedef GetTransformFeedbackVarying::Result Result;
1500 Result* result = static_cast<Result*>(shared_memory_address_);
1501 result->success = 0;
1502 decoder_->set_unsafe_es3_apis_enabled(true);
1503 cmd.Init(client_program_id_,
1504 kIndex,
1505 kBucketId,
1506 kInvalidSharedMemoryId,
1507 shared_memory_offset_);
1508 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1509 cmd.Init(client_program_id_,
1510 kIndex,
1511 kBucketId,
1512 shared_memory_id_,
1513 kInvalidSharedMemoryOffset);
1514 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1517 TEST_P(GLES2DecoderTest, CompileShaderValidArgs) {
1518 // Compile shader should not actually call any GL calls yet.
1519 CompileShader cmd;
1520 cmd.Init(client_shader_id_);
1521 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1523 // Getting the shader compilation state should trigger the actual GL calls.
1524 EXPECT_CALL(*gl_, ShaderSource(kServiceShaderId, 1, _, _));
1525 EXPECT_CALL(*gl_, CompileShader(kServiceShaderId));
1526 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_COMPILE_STATUS, _))
1527 .WillOnce(SetArgPointee<2>(GL_TRUE))
1528 .RetiresOnSaturation();
1529 EXPECT_CALL(*gl_, GetError())
1530 .WillOnce(Return(GL_NO_ERROR))
1531 .WillOnce(Return(GL_NO_ERROR))
1532 .RetiresOnSaturation();
1534 GetShaderiv status_cmd;
1535 status_cmd.Init(client_shader_id_, GL_COMPILE_STATUS,
1536 kSharedMemoryId, kSharedMemoryOffset);
1537 EXPECT_EQ(error::kNoError, ExecuteCmd(status_cmd));
1540 TEST_P(GLES2DecoderTest, CompileShaderInvalidArgs) {
1541 CompileShader cmd;
1542 cmd.Init(kInvalidClientId);
1543 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1544 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1545 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS
1546 cmd.Init(client_program_id_);
1547 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1548 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1549 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS
1552 TEST_P(GLES2DecoderTest, ShaderSourceBucketAndGetShaderSourceValidArgs) {
1553 const uint32 kInBucketId = 123;
1554 const uint32 kOutBucketId = 125;
1555 const char kSource0[] = "hello";
1556 const char* kSource[] = { kSource0 };
1557 const char kValidStrEnd = 0;
1558 SetBucketAsCStrings(kInBucketId, 1, kSource, 1, kValidStrEnd);
1559 ShaderSourceBucket cmd;
1560 cmd.Init(client_shader_id_, kInBucketId);
1561 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1562 ClearSharedMemory();
1563 GetShaderSource get_cmd;
1564 get_cmd.Init(client_shader_id_, kOutBucketId);
1565 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd));
1566 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kOutBucketId);
1567 ASSERT_TRUE(bucket != NULL);
1568 EXPECT_EQ(sizeof(kSource0), bucket->size());
1569 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()),
1570 kSource0, bucket->size()));
1573 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS
1574 TEST_P(GLES2DecoderTest, ShaderSourceBucketWithProgramId) {
1575 const uint32 kBucketId = 123;
1576 const char kSource0[] = "hello";
1577 const char* kSource[] = { kSource0 };
1578 const char kValidStrEnd = 0;
1579 SetBucketAsCStrings(kBucketId, 1, kSource, 1, kValidStrEnd);
1580 ShaderSourceBucket cmd;
1581 cmd.Init(client_program_id_, kBucketId);
1582 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1583 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1585 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS
1587 TEST_P(GLES2DecoderTest, ShaderSourceStripComments) {
1588 const uint32 kInBucketId = 123;
1589 const char kSource0[] = "hello/*te\ast*/world//a\ab";
1590 const char* kSource[] = { kSource0 };
1591 const char kValidStrEnd = 0;
1592 SetBucketAsCStrings(kInBucketId, 1, kSource, 1, kValidStrEnd);
1593 ShaderSourceBucket cmd;
1594 cmd.Init(client_shader_id_, kInBucketId);
1595 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1596 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1599 TEST_P(GLES2DecoderWithShaderTest, Uniform1iValidArgs) {
1600 EXPECT_CALL(*gl_, Uniform1i(kUniform1RealLocation, 2));
1601 Uniform1i cmd;
1602 cmd.Init(kUniform1FakeLocation, 2);
1603 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1606 TEST_P(GLES2DecoderWithShaderTest, Uniform1ivImmediateValidArgs) {
1607 Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>();
1608 EXPECT_CALL(*gl_,
1609 Uniform1iv(kUniform1RealLocation,
1611 reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd))));
1612 GLint temp[1 * 2] = {
1615 cmd.Init(kUniform1FakeLocation, 1, &temp[0]);
1616 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp)));
1619 TEST_P(GLES2DecoderWithShaderTest, Uniform1ivImmediateInvalidValidArgs) {
1620 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0);
1621 Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>();
1622 GLint temp[1 * 2] = {
1625 cmd.Init(kUniform1FakeLocation, 2, &temp[0]);
1626 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp)));
1627 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1630 TEST_P(GLES2DecoderWithShaderTest, Uniform1ivZeroCount) {
1631 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0);
1632 Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>();
1633 GLint temp = 0;
1634 cmd.Init(kUniform1FakeLocation, 0, &temp);
1635 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp)));
1636 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1639 TEST_P(GLES2DecoderWithShaderTest, Uniform1iSamplerIsLmited) {
1640 EXPECT_CALL(*gl_, Uniform1i(_, _)).Times(0);
1641 Uniform1i cmd;
1642 cmd.Init(kUniform1FakeLocation, kNumTextureUnits);
1643 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1644 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1647 TEST_P(GLES2DecoderWithShaderTest, Uniform1ivSamplerIsLimited) {
1648 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0);
1649 Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>();
1650 GLint temp[] = {kNumTextureUnits};
1651 cmd.Init(kUniform1FakeLocation, 1, &temp[0]);
1652 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp)));
1653 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1656 TEST_P(GLES2DecoderTest, BindAttribLocationBucket) {
1657 const uint32 kBucketId = 123;
1658 const GLint kLocation = 2;
1659 const char* kName = "testing";
1660 EXPECT_CALL(*gl_,
1661 BindAttribLocation(kServiceProgramId, kLocation, StrEq(kName)))
1662 .Times(1);
1663 SetBucketAsCString(kBucketId, kName);
1664 BindAttribLocationBucket cmd;
1665 cmd.Init(client_program_id_, kLocation, kBucketId);
1666 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1669 TEST_P(GLES2DecoderTest, BindAttribLocationBucketInvalidArgs) {
1670 const uint32 kBucketId = 123;
1671 const GLint kLocation = 2;
1672 const char* kName = "testing";
1673 EXPECT_CALL(*gl_, BindAttribLocation(_, _, _)).Times(0);
1674 BindAttribLocationBucket cmd;
1675 // check bucket does not exist.
1676 cmd.Init(client_program_id_, kLocation, kBucketId);
1677 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1678 // check bucket is empty.
1679 SetBucketAsCString(kBucketId, NULL);
1680 cmd.Init(client_program_id_, kLocation, kBucketId);
1681 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1682 // Check bad program id
1683 SetBucketAsCString(kBucketId, kName);
1684 cmd.Init(kInvalidClientId, kLocation, kBucketId);
1685 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1686 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1689 TEST_P(GLES2DecoderWithShaderTest, GetAttribLocation) {
1690 const uint32 kBucketId = 123;
1691 const char* kNonExistentName = "foobar";
1692 typedef GetAttribLocation::Result Result;
1693 Result* result = GetSharedMemoryAs<Result*>();
1694 SetBucketAsCString(kBucketId, kAttrib2Name);
1695 *result = -1;
1696 GetAttribLocation cmd;
1697 cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1698 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1699 EXPECT_EQ(kAttrib2Location, *result);
1700 SetBucketAsCString(kBucketId, kNonExistentName);
1701 *result = -1;
1702 cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1703 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1704 EXPECT_EQ(-1, *result);
1707 TEST_P(GLES2DecoderWithShaderTest, GetAttribLocationInvalidArgs) {
1708 const uint32 kBucketId = 123;
1709 typedef GetAttribLocation::Result Result;
1710 Result* result = GetSharedMemoryAs<Result*>();
1711 *result = -1;
1712 GetAttribLocation cmd;
1713 // Check no bucket
1714 cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1715 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1716 EXPECT_EQ(-1, *result);
1717 // Check bad program id.
1718 SetBucketAsCString(kBucketId, kAttrib2Name);
1719 cmd.Init(kInvalidClientId, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1720 *result = -1;
1721 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1722 EXPECT_EQ(-1, *result);
1723 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1724 // Check bad memory
1725 cmd.Init(client_program_id_,
1726 kBucketId,
1727 kInvalidSharedMemoryId,
1728 kSharedMemoryOffset);
1729 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1730 cmd.Init(client_program_id_,
1731 kBucketId,
1732 kSharedMemoryId,
1733 kInvalidSharedMemoryOffset);
1734 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1737 TEST_P(GLES2DecoderWithShaderTest, GetFragDataLocation) {
1738 const uint32 kBucketId = 123;
1739 const GLint kLocation = 10;
1740 const char* kName = "color";
1741 typedef GetFragDataLocation::Result Result;
1742 Result* result = GetSharedMemoryAs<Result*>();
1743 SetBucketAsCString(kBucketId, kName);
1744 *result = -1;
1745 GetFragDataLocation cmd;
1746 cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1747 EXPECT_CALL(*gl_, GetFragDataLocation(kServiceProgramId, StrEq(kName)))
1748 .WillOnce(Return(kLocation))
1749 .RetiresOnSaturation();
1750 decoder_->set_unsafe_es3_apis_enabled(true);
1751 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1752 EXPECT_EQ(kLocation, *result);
1753 decoder_->set_unsafe_es3_apis_enabled(false);
1754 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
1757 TEST_P(GLES2DecoderWithShaderTest, GetFragDataLocationInvalidArgs) {
1758 const uint32 kBucketId = 123;
1759 typedef GetFragDataLocation::Result Result;
1760 Result* result = GetSharedMemoryAs<Result*>();
1761 *result = -1;
1762 GetFragDataLocation cmd;
1763 decoder_->set_unsafe_es3_apis_enabled(true);
1764 // Check no bucket
1765 cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1766 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1767 EXPECT_EQ(-1, *result);
1768 // Check bad program id.
1769 const char* kName = "color";
1770 SetBucketAsCString(kBucketId, kName);
1771 cmd.Init(kInvalidClientId, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1772 *result = -1;
1773 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1774 EXPECT_EQ(-1, *result);
1775 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1776 // Check bad memory
1777 cmd.Init(client_program_id_,
1778 kBucketId,
1779 kInvalidSharedMemoryId,
1780 kSharedMemoryOffset);
1781 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1782 cmd.Init(client_program_id_,
1783 kBucketId,
1784 kSharedMemoryId,
1785 kInvalidSharedMemoryOffset);
1786 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1789 TEST_P(GLES2DecoderWithShaderTest, GetUniformBlockIndex) {
1790 const uint32 kBucketId = 123;
1791 const GLuint kIndex = 10;
1792 const char* kName = "color";
1793 typedef GetUniformBlockIndex::Result Result;
1794 Result* result = GetSharedMemoryAs<Result*>();
1795 SetBucketAsCString(kBucketId, kName);
1796 *result = GL_INVALID_INDEX;
1797 GetUniformBlockIndex cmd;
1798 cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1799 EXPECT_CALL(*gl_, GetUniformBlockIndex(kServiceProgramId, StrEq(kName)))
1800 .WillOnce(Return(kIndex))
1801 .RetiresOnSaturation();
1802 decoder_->set_unsafe_es3_apis_enabled(true);
1803 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1804 EXPECT_EQ(kIndex, *result);
1805 decoder_->set_unsafe_es3_apis_enabled(false);
1806 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
1809 TEST_P(GLES2DecoderWithShaderTest, GetUniformBlockIndexInvalidArgs) {
1810 const uint32 kBucketId = 123;
1811 typedef GetUniformBlockIndex::Result Result;
1812 Result* result = GetSharedMemoryAs<Result*>();
1813 *result = GL_INVALID_INDEX;
1814 GetUniformBlockIndex cmd;
1815 decoder_->set_unsafe_es3_apis_enabled(true);
1816 // Check no bucket
1817 cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1818 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1819 EXPECT_EQ(GL_INVALID_INDEX, *result);
1820 // Check bad program id.
1821 const char* kName = "color";
1822 SetBucketAsCString(kBucketId, kName);
1823 cmd.Init(kInvalidClientId, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1824 *result = GL_INVALID_INDEX;
1825 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1826 EXPECT_EQ(GL_INVALID_INDEX, *result);
1827 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1828 // Check bad memory
1829 cmd.Init(client_program_id_,
1830 kBucketId,
1831 kInvalidSharedMemoryId,
1832 kSharedMemoryOffset);
1833 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1834 cmd.Init(client_program_id_,
1835 kBucketId,
1836 kSharedMemoryId,
1837 kInvalidSharedMemoryOffset);
1838 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1841 TEST_P(GLES2DecoderWithShaderTest, GetUniformLocation) {
1842 const uint32 kBucketId = 123;
1843 const char* kNonExistentName = "foobar";
1844 typedef GetUniformLocation::Result Result;
1845 Result* result = GetSharedMemoryAs<Result*>();
1846 SetBucketAsCString(kBucketId, kUniform2Name);
1847 *result = -1;
1848 GetUniformLocation cmd;
1849 cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1850 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1851 EXPECT_EQ(kUniform2FakeLocation, *result);
1852 SetBucketAsCString(kBucketId, kNonExistentName);
1853 *result = -1;
1854 cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1855 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1856 EXPECT_EQ(-1, *result);
1859 TEST_P(GLES2DecoderWithShaderTest, GetUniformLocationInvalidArgs) {
1860 const uint32 kBucketId = 123;
1861 typedef GetUniformLocation::Result Result;
1862 Result* result = GetSharedMemoryAs<Result*>();
1863 *result = -1;
1864 GetUniformLocation cmd;
1865 // Check no bucket
1866 cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1867 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1868 EXPECT_EQ(-1, *result);
1869 // Check bad program id.
1870 SetBucketAsCString(kBucketId, kUniform2Name);
1871 cmd.Init(kInvalidClientId, kBucketId, kSharedMemoryId, kSharedMemoryOffset);
1872 *result = -1;
1873 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1874 EXPECT_EQ(-1, *result);
1875 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1876 // Check bad memory
1877 cmd.Init(client_program_id_,
1878 kBucketId,
1879 kInvalidSharedMemoryId,
1880 kSharedMemoryOffset);
1881 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1882 cmd.Init(client_program_id_,
1883 kBucketId,
1884 kSharedMemoryId,
1885 kInvalidSharedMemoryOffset);
1886 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1889 TEST_P(GLES2DecoderWithShaderTest, UniformBlockBindingValidArgs) {
1890 EXPECT_CALL(*gl_, UniformBlockBinding(kServiceProgramId, 2, 3));
1891 SpecializedSetup<cmds::UniformBlockBinding, 0>(true);
1892 cmds::UniformBlockBinding cmd;
1893 cmd.Init(client_program_id_, 2, 3);
1894 decoder_->set_unsafe_es3_apis_enabled(true);
1895 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1896 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1897 decoder_->set_unsafe_es3_apis_enabled(false);
1898 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
1901 TEST_P(GLES2DecoderWithShaderTest, BindUniformLocationCHROMIUMBucket) {
1902 const uint32 kBucketId = 123;
1903 const GLint kLocation = 2;
1904 const char* kName = "testing";
1905 const char* kBadName1 = "gl_testing";
1906 const char* kBadName2 = "testing[1]";
1908 SetBucketAsCString(kBucketId, kName);
1909 BindUniformLocationCHROMIUMBucket cmd;
1910 cmd.Init(client_program_id_,
1911 kLocation,
1912 kBucketId);
1913 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1914 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1915 // check negative location
1916 SetBucketAsCString(kBucketId, kName);
1917 cmd.Init(client_program_id_, -1, kBucketId);
1918 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1919 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1920 // check highest location
1921 SetBucketAsCString(kBucketId, kName);
1922 GLint kMaxLocation =
1923 (kMaxFragmentUniformVectors + kMaxVertexUniformVectors) * 4 - 1;
1924 cmd.Init(client_program_id_,
1925 kMaxLocation,
1926 kBucketId);
1927 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1928 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1929 // check too high location
1930 SetBucketAsCString(kBucketId, kName);
1931 cmd.Init(client_program_id_,
1932 kMaxLocation + 1,
1933 kBucketId);
1934 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1935 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1936 // check bad name "gl_..."
1937 SetBucketAsCString(kBucketId, kBadName1);
1938 cmd.Init(client_program_id_,
1939 kLocation,
1940 kBucketId);
1941 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1942 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1943 // check bad name "name[1]" non zero
1944 SetBucketAsCString(kBucketId, kBadName2);
1945 cmd.Init(client_program_id_,
1946 kLocation,
1947 kBucketId);
1948 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1949 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1952 TEST_P(GLES2DecoderManualInitTest, ClearUniformsBeforeFirstProgramUse) {
1953 base::CommandLine command_line(0, NULL);
1954 command_line.AppendSwitchASCII(
1955 switches::kGpuDriverBugWorkarounds,
1956 base::IntToString(gpu::CLEAR_UNIFORMS_BEFORE_FIRST_PROGRAM_USE));
1957 InitState init;
1958 init.has_alpha = true;
1959 init.request_alpha = true;
1960 init.bind_generates_resource = true;
1961 InitDecoderWithCommandLine(init, &command_line);
1963 static AttribInfo attribs[] = {
1965 kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location,
1968 kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location,
1971 kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location,
1974 static UniformInfo uniforms[] = {
1975 {kUniform1Name, kUniform1Size, kUniform1Type, kUniform1FakeLocation,
1976 kUniform1RealLocation, kUniform1DesiredLocation},
1977 {kUniform2Name, kUniform2Size, kUniform2Type, kUniform2FakeLocation,
1978 kUniform2RealLocation, kUniform2DesiredLocation},
1979 {kUniform3Name, kUniform3Size, kUniform3Type, kUniform3FakeLocation,
1980 kUniform3RealLocation, kUniform3DesiredLocation},
1982 SetupShader(attribs,
1983 arraysize(attribs),
1984 uniforms,
1985 arraysize(uniforms),
1986 client_program_id_,
1987 kServiceProgramId,
1988 client_vertex_shader_id_,
1989 kServiceVertexShaderId,
1990 client_fragment_shader_id_,
1991 kServiceFragmentShaderId);
1992 TestHelper::SetupExpectationsForClearingUniforms(
1993 gl_.get(), uniforms, arraysize(uniforms));
1997 EXPECT_CALL(*gl_, UseProgram(kServiceProgramId))
1998 .Times(1)
1999 .RetiresOnSaturation();
2000 cmds::UseProgram cmd;
2001 cmd.Init(client_program_id_);
2002 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2006 // TODO(gman): DeleteProgram
2008 // TODO(gman): UseProgram
2010 // TODO(gman): DeleteShader
2012 } // namespace gles2
2013 } // namespace gpu