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
3 // found in the LICENSE file.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_
8 #include "gpu/command_buffer/common/gles2_cmd_format.h"
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
10 #include "gpu/command_buffer/service/buffer_manager.h"
11 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
12 #include "gpu/command_buffer/service/context_group.h"
13 #include "gpu/command_buffer/service/framebuffer_manager.h"
14 #include "gpu/command_buffer/service/gl_context_mock.h"
15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
16 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
17 #include "gpu/command_buffer/service/program_manager.h"
18 #include "gpu/command_buffer/service/query_manager.h"
19 #include "gpu/command_buffer/service/renderbuffer_manager.h"
20 #include "gpu/command_buffer/service/shader_manager.h"
21 #include "gpu/command_buffer/service/test_helper.h"
22 #include "gpu/command_buffer/service/texture_manager.h"
23 #include "gpu/command_buffer/service/valuebuffer_manager.h"
24 #include "gpu/command_buffer/service/vertex_array_manager.h"
25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "ui/gl/gl_surface_stub.h"
27 #include "ui/gl/gl_mock.h"
38 class GLES2DecoderTestBase
: public ::testing::TestWithParam
<bool> {
40 GLES2DecoderTestBase();
41 virtual ~GLES2DecoderTestBase();
43 // Template to call glGenXXX functions.
45 void GenHelper(GLuint client_id
) {
46 int8 buffer
[sizeof(T
) + sizeof(client_id
)];
47 T
& cmd
= *reinterpret_cast<T
*>(&buffer
);
48 cmd
.Init(1, &client_id
);
49 EXPECT_EQ(error::kNoError
,
50 ExecuteImmediateCmd(cmd
, sizeof(client_id
)));
53 // This template exists solely so we can specialize it for
55 template <typename T
, int id
>
56 void SpecializedSetup(bool valid
) {
61 return reinterpret_cast<T
*>(immediate_buffer_
);
64 template <typename T
, typename Command
>
65 T
GetImmediateDataAs(Command
* cmd
) {
66 return reinterpret_cast<T
>(ImmediateDataAddress(cmd
));
69 void ClearSharedMemory() {
70 engine_
->ClearSharedMemory();
73 void SetUp() override
;
74 void TearDown() override
;
77 error::Error
ExecuteCmd(const T
& cmd
) {
78 static_assert(T::kArgFlags
== cmd::kFixed
,
79 "T::kArgFlags should equal cmd::kFixed");
80 return decoder_
->DoCommands(
81 1, (const void*)&cmd
, ComputeNumEntries(sizeof(cmd
)), 0);
85 error::Error
ExecuteImmediateCmd(const T
& cmd
, size_t data_size
) {
86 static_assert(T::kArgFlags
== cmd::kAtLeastN
,
87 "T::kArgFlags should equal cmd::kAtLeastN");
88 return decoder_
->DoCommands(
89 1, (const void*)&cmd
, ComputeNumEntries(sizeof(cmd
) + data_size
), 0);
93 T
GetSharedMemoryAs() {
94 return reinterpret_cast<T
>(shared_memory_address_
);
98 T
GetSharedMemoryAsWithOffset(uint32 offset
) {
99 void* ptr
= reinterpret_cast<int8
*>(shared_memory_address_
) + offset
;
100 return reinterpret_cast<T
>(ptr
);
103 Buffer
* GetBuffer(GLuint service_id
) {
104 return group_
->buffer_manager()->GetBuffer(service_id
);
107 Framebuffer
* GetFramebuffer(GLuint service_id
) {
108 return group_
->framebuffer_manager()->GetFramebuffer(service_id
);
111 Renderbuffer
* GetRenderbuffer(
113 return group_
->renderbuffer_manager()->GetRenderbuffer(service_id
);
116 TextureRef
* GetTexture(GLuint client_id
) {
117 return group_
->texture_manager()->GetTexture(client_id
);
120 Shader
* GetShader(GLuint client_id
) {
121 return group_
->shader_manager()->GetShader(client_id
);
124 Program
* GetProgram(GLuint client_id
) {
125 return group_
->program_manager()->GetProgram(client_id
);
128 Valuebuffer
* GetValuebuffer(GLuint client_id
) {
129 return group_
->valuebuffer_manager()->GetValuebuffer(client_id
);
132 QueryManager::Query
* GetQueryInfo(GLuint client_id
) {
133 return decoder_
->GetQueryManager()->GetQuery(client_id
);
136 bool GetSamplerServiceId(GLuint client_id
, GLuint
* service_id
) const {
137 return group_
->GetSamplerServiceId(client_id
, service_id
);
140 bool GetTransformFeedbackServiceId(
141 GLuint client_id
, GLuint
* service_id
) const {
142 return group_
->GetTransformFeedbackServiceId(client_id
, service_id
);
145 bool GetSyncServiceId(GLuint client_id
, GLsync
* service_id
) const {
146 return group_
->GetSyncServiceId(client_id
, service_id
);
149 // This name doesn't match the underlying function, but doing it this way
150 // prevents the need to special-case the unit test generation
151 VertexAttribManager
* GetVertexArrayInfo(GLuint client_id
) {
152 return decoder_
->GetVertexArrayManager()->GetVertexAttribManager(client_id
);
155 ProgramManager
* program_manager() {
156 return group_
->program_manager();
159 ValuebufferManager
* valuebuffer_manager() {
160 return group_
->valuebuffer_manager();
163 ValueStateMap
* pending_valuebuffer_state() {
164 return group_
->pending_valuebuffer_state();
167 FeatureInfo
* feature_info() {
168 return group_
->feature_info();
171 ImageManager
* GetImageManager() { return decoder_
->GetImageManager(); }
173 void DoCreateProgram(GLuint client_id
, GLuint service_id
);
174 void DoCreateShader(GLenum shader_type
, GLuint client_id
, GLuint service_id
);
175 void DoFenceSync(GLuint client_id
, GLuint service_id
);
177 void SetBucketData(uint32_t bucket_id
, const void* data
, uint32_t data_size
);
178 void SetBucketAsCString(uint32 bucket_id
, const char* str
);
179 // If we want a valid bucket, just set |count_in_header| as |count|,
180 // and set |str_end| as 0.
181 void SetBucketAsCStrings(uint32 bucket_id
, GLsizei count
, const char** str
,
182 GLsizei count_in_header
, char str_end
);
184 void set_memory_tracker(MemoryTracker
* memory_tracker
) {
185 memory_tracker_
= memory_tracker
;
191 std::string extensions
;
192 std::string gl_version
;
198 bool request_stencil
;
199 bool bind_generates_resource
;
200 bool lose_context_when_out_of_memory
;
201 bool use_native_vao
; // default is true.
204 void InitDecoder(const InitState
& init
);
205 void InitDecoderWithCommandLine(const InitState
& init
,
206 const base::CommandLine
* command_line
);
210 const ContextGroup
& group() const {
211 return *group_
.get();
214 void LoseContexts(error::ContextLostReason reason
) const {
215 group_
->LoseContexts(reason
);
218 ::testing::StrictMock
< ::gfx::MockGLInterface
>* GetGLMock() const {
222 GLES2Decoder
* GetDecoder() const {
223 return decoder_
.get();
226 typedef TestHelper::AttribInfo AttribInfo
;
227 typedef TestHelper::UniformInfo UniformInfo
;
230 AttribInfo
* attribs
, size_t num_attribs
,
231 UniformInfo
* uniforms
, size_t num_uniforms
,
232 GLuint client_id
, GLuint service_id
,
233 GLuint vertex_shader_client_id
, GLuint vertex_shader_service_id
,
234 GLuint fragment_shader_client_id
, GLuint fragment_shader_service_id
);
236 void SetupInitCapabilitiesExpectations(bool es3_capable
);
237 void SetupInitStateExpectations();
238 void ExpectEnableDisable(GLenum cap
, bool enable
);
240 // Setups up a shader for testing glUniform.
241 void SetupShaderForUniform(GLenum uniform_type
);
242 void SetupDefaultProgram();
243 void SetupCubemapProgram();
244 void SetupSamplerExternalProgram();
247 // Note that the error is returned as GLint instead of GLenum.
248 // This is because there is a mismatch in the types of GLenum and
249 // the error values GL_NO_ERROR, GL_INVALID_ENUM, etc. GLenum is
250 // typedef'd as unsigned int while the error values are defined as
251 // integers. This is problematic for template functions such as
252 // EXPECT_EQ that expect both types to be the same.
255 void DoBindBuffer(GLenum target
, GLuint client_id
, GLuint service_id
);
256 void DoBindFramebuffer(GLenum target
, GLuint client_id
, GLuint service_id
);
257 void DoBindRenderbuffer(GLenum target
, GLuint client_id
, GLuint service_id
);
258 void DoRenderbufferStorageMultisampleCHROMIUM(GLenum target
,
260 GLenum internal_format
,
264 void RestoreRenderbufferBindings();
265 void EnsureRenderbufferBound(bool expect_bind
);
266 void DoBindTexture(GLenum target
, GLuint client_id
, GLuint service_id
);
267 void DoBindVertexArrayOES(GLuint client_id
, GLuint service_id
);
269 bool DoIsBuffer(GLuint client_id
);
270 bool DoIsFramebuffer(GLuint client_id
);
271 bool DoIsProgram(GLuint client_id
);
272 bool DoIsRenderbuffer(GLuint client_id
);
273 bool DoIsShader(GLuint client_id
);
274 bool DoIsTexture(GLuint client_id
);
276 void DoDeleteBuffer(GLuint client_id
, GLuint service_id
);
277 void DoDeleteFramebuffer(
278 GLuint client_id
, GLuint service_id
,
279 bool reset_draw
, GLenum draw_target
, GLuint draw_id
,
280 bool reset_read
, GLenum read_target
, GLuint read_id
);
281 void DoDeleteProgram(GLuint client_id
, GLuint service_id
);
282 void DoDeleteRenderbuffer(GLuint client_id
, GLuint service_id
);
283 void DoDeleteShader(GLuint client_id
, GLuint service_id
);
284 void DoDeleteTexture(GLuint client_id
, GLuint service_id
);
286 void DoCompressedTexImage2D(
287 GLenum target
, GLint level
, GLenum format
,
288 GLsizei width
, GLsizei height
, GLint border
,
289 GLsizei size
, uint32 bucket_id
);
290 void DoBindTexImage2DCHROMIUM(GLenum target
, GLint image_id
);
292 GLenum target
, GLint level
, GLenum internal_format
,
293 GLsizei width
, GLsizei height
, GLint border
,
294 GLenum format
, GLenum type
,
295 uint32 shared_memory_id
, uint32 shared_memory_offset
);
296 void DoTexImage2DConvertInternalFormat(
297 GLenum target
, GLint level
, GLenum requested_internal_format
,
298 GLsizei width
, GLsizei height
, GLint border
,
299 GLenum format
, GLenum type
,
300 uint32 shared_memory_id
, uint32 shared_memory_offset
,
301 GLenum expected_internal_format
);
302 void DoRenderbufferStorage(
303 GLenum target
, GLenum internal_format
, GLenum actual_format
,
304 GLsizei width
, GLsizei height
, GLenum error
);
305 void DoFramebufferRenderbuffer(
308 GLenum renderbuffer_target
,
309 GLuint renderbuffer_client_id
,
310 GLuint renderbuffer_service_id
,
312 void DoFramebufferTexture2D(
313 GLenum target
, GLenum attachment
, GLenum tex_target
,
314 GLuint texture_client_id
, GLuint texture_service_id
,
315 GLint level
, GLenum error
);
316 void DoVertexAttribPointer(
317 GLuint index
, GLint size
, GLenum type
, GLsizei stride
, GLuint offset
);
318 void DoVertexAttribDivisorANGLE(GLuint index
, GLuint divisor
);
320 void DoEnableDisable(GLenum cap
, bool enable
);
322 void DoEnableVertexAttribArray(GLint index
);
324 void DoBufferData(GLenum target
, GLsizei size
);
326 void DoBufferSubData(
327 GLenum target
, GLint offset
, GLsizei size
, const void* data
);
329 void SetupVertexBuffer();
330 void SetupAllNeededVertexBuffers();
332 void SetupIndexBuffer();
334 void DeleteVertexBuffer();
336 void DeleteIndexBuffer();
338 void SetupClearTextureExpectations(
340 GLuint old_service_id
,
344 GLenum internal_format
,
350 void SetupExpectationsForRestoreClearState(
351 GLclampf restore_red
,
352 GLclampf restore_green
,
353 GLclampf restore_blue
,
354 GLclampf restore_alpha
,
355 GLuint restore_stencil
,
356 GLclampf restore_depth
,
357 bool restore_scissor_test
);
359 void SetupExpectationsForFramebufferClearing(
362 GLclampf restore_red
,
363 GLclampf restore_green
,
364 GLclampf restore_blue
,
365 GLclampf restore_alpha
,
366 GLuint restore_stencil
,
367 GLclampf restore_depth
,
368 bool restore_scissor_test
);
370 void SetupExpectationsForFramebufferClearingMulti(
371 GLuint read_framebuffer_service_id
,
372 GLuint draw_framebuffer_service_id
,
375 GLclampf restore_red
,
376 GLclampf restore_green
,
377 GLclampf restore_blue
,
378 GLclampf restore_alpha
,
379 GLuint restore_stencil
,
380 GLclampf restore_depth
,
381 bool restore_scissor_test
);
383 void SetupExpectationsForDepthMask(bool mask
);
384 void SetupExpectationsForEnableDisable(GLenum cap
, bool enable
);
385 void SetupExpectationsForColorMask(bool red
,
389 void SetupExpectationsForStencilMask(GLuint front_mask
, GLuint back_mask
);
391 void SetupExpectationsForApplyingDirtyState(
392 bool framebuffer_is_rgb
,
393 bool framebuffer_has_depth
,
394 bool framebuffer_has_stencil
,
395 GLuint color_bits
, // NOTE! bits are 0x1000, 0x0100, 0x0010, and 0x0001
398 GLuint front_stencil_mask
,
399 GLuint back_stencil_mask
,
400 bool stencil_enabled
);
402 void SetupExpectationsForApplyingDefaultDirtyState();
404 void AddExpectationsForSimulatedAttrib0WithError(
405 GLsizei num_vertices
, GLuint buffer_id
, GLenum error
);
407 void AddExpectationsForSimulatedAttrib0(
408 GLsizei num_vertices
, GLuint buffer_id
);
410 void AddExpectationsForGenVertexArraysOES();
411 void AddExpectationsForDeleteVertexArraysOES();
412 void AddExpectationsForDeleteBoundVertexArraysOES();
413 void AddExpectationsForBindVertexArrayOES();
414 void AddExpectationsForRestoreAttribState(GLuint attrib
);
416 GLvoid
* BufferOffset(unsigned i
) {
417 return static_cast<int8
*>(NULL
)+(i
);
420 template <typename Command
, typename Result
>
421 bool IsObjectHelper(GLuint client_id
) {
422 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
424 cmd
.Init(client_id
, kSharedMemoryId
, kSharedMemoryOffset
);
425 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
426 bool isObject
= static_cast<bool>(*result
);
427 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
432 static const int kBackBufferWidth
= 128;
433 static const int kBackBufferHeight
= 64;
435 static const GLint kMaxTextureSize
= 2048;
436 static const GLint kMaxCubeMapTextureSize
= 256;
437 static const GLint kNumVertexAttribs
= 16;
438 static const GLint kNumTextureUnits
= 8;
439 static const GLint kMaxTextureImageUnits
= 8;
440 static const GLint kMaxVertexTextureImageUnits
= 2;
441 static const GLint kMaxFragmentUniformVectors
= 16;
442 static const GLint kMaxVaryingVectors
= 8;
443 static const GLint kMaxVertexUniformVectors
= 128;
444 static const GLint kMaxViewportWidth
= 8192;
445 static const GLint kMaxViewportHeight
= 8192;
447 static const GLint kViewportX
= 0;
448 static const GLint kViewportY
= 0;
449 static const GLint kViewportWidth
= kBackBufferWidth
;
450 static const GLint kViewportHeight
= kBackBufferHeight
;
452 static const GLuint kServiceAttrib0BufferId
= 801;
453 static const GLuint kServiceFixedAttribBufferId
= 802;
455 static const GLuint kServiceBufferId
= 301;
456 static const GLuint kServiceFramebufferId
= 302;
457 static const GLuint kServiceRenderbufferId
= 303;
458 static const GLuint kServiceTextureId
= 304;
459 static const GLuint kServiceProgramId
= 305;
460 static const GLuint kServiceSamplerId
= 306;
461 static const GLuint kServiceShaderId
= 307;
462 static const GLuint kServiceElementBufferId
= 308;
463 static const GLuint kServiceQueryId
= 309;
464 static const GLuint kServiceVertexArrayId
= 310;
465 static const GLuint kServiceTransformFeedbackId
= 311;
466 static const GLuint kServiceSyncId
= 312;
468 static const int32 kSharedMemoryId
= 401;
469 static const size_t kSharedBufferSize
= 2048;
470 static const uint32 kSharedMemoryOffset
= 132;
471 static const int32 kInvalidSharedMemoryId
= 402;
472 static const uint32 kInvalidSharedMemoryOffset
= kSharedBufferSize
+ 1;
473 static const uint32 kInitialResult
= 0xBDBDBDBDu
;
474 static const uint8 kInitialMemoryValue
= 0xBDu
;
476 static const uint32 kNewClientId
= 501;
477 static const uint32 kNewServiceId
= 502;
478 static const uint32 kInvalidClientId
= 601;
480 static const GLuint kServiceVertexShaderId
= 321;
481 static const GLuint kServiceFragmentShaderId
= 322;
483 static const GLuint kServiceCopyTextureChromiumShaderId
= 701;
484 static const GLuint kServiceCopyTextureChromiumProgramId
= 721;
486 static const GLuint kServiceCopyTextureChromiumTextureBufferId
= 751;
487 static const GLuint kServiceCopyTextureChromiumVertexBufferId
= 752;
488 static const GLuint kServiceCopyTextureChromiumFBOId
= 753;
489 static const GLuint kServiceCopyTextureChromiumPositionAttrib
= 761;
490 static const GLuint kServiceCopyTextureChromiumTexAttrib
= 762;
491 static const GLuint kServiceCopyTextureChromiumSamplerLocation
= 763;
493 static const GLsizei kNumVertices
= 100;
494 static const GLsizei kNumIndices
= 10;
495 static const int kValidIndexRangeStart
= 1;
496 static const int kValidIndexRangeCount
= 7;
497 static const int kInvalidIndexRangeStart
= 0;
498 static const int kInvalidIndexRangeCount
= 7;
499 static const int kOutOfRangeIndexRangeEnd
= 10;
500 static const GLuint kMaxValidIndex
= 7;
502 static const GLint kMaxAttribLength
= 10;
503 static const char* kAttrib1Name
;
504 static const char* kAttrib2Name
;
505 static const char* kAttrib3Name
;
506 static const GLint kAttrib1Size
= 1;
507 static const GLint kAttrib2Size
= 1;
508 static const GLint kAttrib3Size
= 1;
509 static const GLint kAttrib1Location
= 0;
510 static const GLint kAttrib2Location
= 1;
511 static const GLint kAttrib3Location
= 2;
512 static const GLenum kAttrib1Type
= GL_FLOAT_VEC4
;
513 static const GLenum kAttrib2Type
= GL_FLOAT_VEC2
;
514 static const GLenum kAttrib3Type
= GL_FLOAT_VEC3
;
515 static const GLint kInvalidAttribLocation
= 30;
516 static const GLint kBadAttribIndex
= kNumVertexAttribs
;
518 static const GLint kMaxUniformLength
= 12;
519 static const char* kUniform1Name
;
520 static const char* kUniform2Name
;
521 static const char* kUniform3Name
;
522 static const GLint kUniform1Size
= 1;
523 static const GLint kUniform2Size
= 3;
524 static const GLint kUniform3Size
= 2;
525 static const GLint kUniform1RealLocation
= 3;
526 static const GLint kUniform2RealLocation
= 10;
527 static const GLint kUniform2ElementRealLocation
= 12;
528 static const GLint kUniform3RealLocation
= 20;
529 static const GLint kUniform1FakeLocation
= 0; // These are
530 static const GLint kUniform2FakeLocation
= 1; // hardcoded
531 static const GLint kUniform2ElementFakeLocation
= 0x10001; // to match
532 static const GLint kUniform3FakeLocation
= 2; // ProgramManager.
533 static const GLint kUniform1DesiredLocation
= -1;
534 static const GLint kUniform2DesiredLocation
= -1;
535 static const GLint kUniform3DesiredLocation
= -1;
536 static const GLenum kUniform1Type
= GL_SAMPLER_2D
;
537 static const GLenum kUniform2Type
= GL_INT_VEC2
;
538 static const GLenum kUniform3Type
= GL_FLOAT_VEC3
;
539 static const GLenum kUniformSamplerExternalType
= GL_SAMPLER_EXTERNAL_OES
;
540 static const GLenum kUniformCubemapType
= GL_SAMPLER_CUBE
;
541 static const GLint kInvalidUniformLocation
= 30;
542 static const GLint kBadUniformIndex
= 1000;
544 // Use StrictMock to make 100% sure we know how GL will be called.
545 scoped_ptr
< ::testing::StrictMock
< ::gfx::MockGLInterface
> > gl_
;
546 scoped_refptr
<gfx::GLSurfaceStub
> surface_
;
547 scoped_refptr
<GLContextMock
> context_
;
548 scoped_ptr
<MockGLES2Decoder
> mock_decoder_
;
549 scoped_ptr
<GLES2Decoder
> decoder_
;
550 MemoryTracker
* memory_tracker_
;
552 GLuint client_buffer_id_
;
553 GLuint client_framebuffer_id_
;
554 GLuint client_program_id_
;
555 GLuint client_renderbuffer_id_
;
556 GLuint client_sampler_id_
;
557 GLuint client_shader_id_
;
558 GLuint client_texture_id_
;
559 GLuint client_element_buffer_id_
;
560 GLuint client_vertex_shader_id_
;
561 GLuint client_fragment_shader_id_
;
562 GLuint client_query_id_
;
563 GLuint client_vertexarray_id_
;
564 GLuint client_valuebuffer_id_
;
565 GLuint client_transformfeedback_id_
;
566 GLuint client_sync_id_
;
568 uint32 shared_memory_id_
;
569 uint32 shared_memory_offset_
;
570 void* shared_memory_address_
;
571 void* shared_memory_base_
;
573 GLuint service_renderbuffer_id_
;
574 bool service_renderbuffer_valid_
;
576 uint32 immediate_buffer_
[64];
578 const bool ignore_cached_state_for_test_
;
579 bool cached_color_mask_red_
;
580 bool cached_color_mask_green_
;
581 bool cached_color_mask_blue_
;
582 bool cached_color_mask_alpha_
;
583 bool cached_depth_mask_
;
584 GLuint cached_stencil_front_mask_
;
585 GLuint cached_stencil_back_mask_
;
590 bool cached_cull_face
;
591 bool cached_depth_test
;
593 bool cached_polygon_offset_fill
;
594 bool cached_sample_alpha_to_coverage
;
595 bool cached_sample_coverage
;
596 bool cached_scissor_test
;
597 bool cached_stencil_test
;
600 EnableFlags enable_flags_
;
603 class MockCommandBufferEngine
: public CommandBufferEngine
{
605 MockCommandBufferEngine();
607 ~MockCommandBufferEngine() override
;
609 scoped_refptr
<gpu::Buffer
> GetSharedMemoryBuffer(int32 shm_id
) override
;
611 void ClearSharedMemory() {
612 memset(valid_buffer_
->memory(), kInitialMemoryValue
, kSharedBufferSize
);
615 void set_token(int32 token
) override
;
617 bool SetGetBuffer(int32
/* transfer_buffer_id */) override
;
619 // Overridden from CommandBufferEngine.
620 bool SetGetOffset(int32 offset
) override
;
622 // Overridden from CommandBufferEngine.
623 int32
GetGetOffset() override
;
626 scoped_refptr
<gpu::Buffer
> valid_buffer_
;
627 scoped_refptr
<gpu::Buffer
> invalid_buffer_
;
630 // MockGLStates is used to track GL states and emulate driver
631 // behaviors on top of MockGLInterface.
635 : bound_array_buffer_object_(0),
636 bound_vertex_array_object_(0) {
642 void OnBindArrayBuffer(GLuint id
) {
643 bound_array_buffer_object_
= id
;
646 void OnBindVertexArrayOES(GLuint id
) {
647 bound_vertex_array_object_
= id
;
650 void OnVertexAttribNullPointer() {
651 // When a vertex array object is bound, some drivers (AMD Linux,
652 // Qualcomm, etc.) have a bug where it incorrectly generates an
653 // GL_INVALID_OPERATION on glVertexAttribPointer() if pointer
654 // is NULL, no buffer is bound on GL_ARRAY_BUFFER.
655 // Make sure we don't trigger this bug.
656 if (bound_vertex_array_object_
!= 0)
657 EXPECT_TRUE(bound_array_buffer_object_
!= 0);
661 GLuint bound_array_buffer_object_
;
662 GLuint bound_vertex_array_object_
;
663 }; // class MockGLStates
665 void AddExpectationsForVertexAttribManager();
666 void SetupMockGLBehaviors();
668 scoped_ptr
< ::testing::StrictMock
<MockCommandBufferEngine
> > engine_
;
669 scoped_refptr
<ContextGroup
> group_
;
670 MockGLStates gl_states_
;
673 class GLES2DecoderWithShaderTestBase
: public GLES2DecoderTestBase
{
675 GLES2DecoderWithShaderTestBase()
676 : GLES2DecoderTestBase() {
680 void SetUp() override
;
681 void TearDown() override
;
684 // SpecializedSetup specializations that are needed in multiple unittest files.
686 void GLES2DecoderTestBase::SpecializedSetup
<cmds::LinkProgram
, 0>(bool valid
);
691 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_