gles2_cmd_decoder_unittest_base.h revision cedac228d2dd51db4b79ea1e72c7f249408ee061
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.
4
5#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_
6#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_
7
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/gles2_cmd_decoder.h"
15#include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
16#include "gpu/command_buffer/service/program_manager.h"
17#include "gpu/command_buffer/service/query_manager.h"
18#include "gpu/command_buffer/service/renderbuffer_manager.h"
19#include "gpu/command_buffer/service/shader_manager.h"
20#include "gpu/command_buffer/service/test_helper.h"
21#include "gpu/command_buffer/service/texture_manager.h"
22#include "gpu/command_buffer/service/vertex_array_manager.h"
23#include "testing/gtest/include/gtest/gtest.h"
24#include "ui/gl/gl_context_stub_with_extensions.h"
25#include "ui/gl/gl_surface_stub.h"
26#include "ui/gl/gl_mock.h"
27
28namespace base {
29class CommandLine;
30}
31
32namespace gpu {
33namespace gles2 {
34
35class MemoryTracker;
36
37class GLES2DecoderTestBase : public ::testing::TestWithParam<bool> {
38 public:
39  GLES2DecoderTestBase();
40  virtual ~GLES2DecoderTestBase();
41
42  // Template to call glGenXXX functions.
43  template <typename T>
44  void GenHelper(GLuint client_id) {
45    int8 buffer[sizeof(T) + sizeof(client_id)];
46    T& cmd = *reinterpret_cast<T*>(&buffer);
47    cmd.Init(1, &client_id);
48    EXPECT_EQ(error::kNoError,
49              ExecuteImmediateCmd(cmd, sizeof(client_id)));
50  }
51
52  // This template exists solely so we can specialize it for
53  // certain commands.
54  template <typename T, int id>
55  void SpecializedSetup(bool valid) {
56  }
57
58  template <typename T>
59  T* GetImmediateAs() {
60    return reinterpret_cast<T*>(immediate_buffer_);
61  }
62
63  template <typename T, typename Command>
64  T GetImmediateDataAs(Command* cmd) {
65    return reinterpret_cast<T>(ImmediateDataAddress(cmd));
66  }
67
68  void ClearSharedMemory() {
69    engine_->ClearSharedMemory();
70  }
71
72  virtual void SetUp() OVERRIDE;
73  virtual void TearDown() OVERRIDE;
74
75  template <typename T>
76  error::Error ExecuteCmd(const T& cmd) {
77    COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed);
78    return decoder_->DoCommand(cmd.kCmdId,
79                               ComputeNumEntries(sizeof(cmd)) - 1,
80                               &cmd);
81  }
82
83  template <typename T>
84  error::Error ExecuteImmediateCmd(const T& cmd, size_t data_size) {
85    COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN);
86    return decoder_->DoCommand(cmd.kCmdId,
87                               ComputeNumEntries(sizeof(cmd) + data_size) - 1,
88                               &cmd);
89  }
90
91  template <typename T>
92  T GetSharedMemoryAs() {
93    return reinterpret_cast<T>(shared_memory_address_);
94  }
95
96  template <typename T>
97  T GetSharedMemoryAsWithOffset(uint32 offset) {
98    void* ptr = reinterpret_cast<int8*>(shared_memory_address_) + offset;
99    return reinterpret_cast<T>(ptr);
100  }
101
102  IdAllocatorInterface* GetIdAllocator(GLuint namespace_id) {
103    return group_->GetIdAllocator(namespace_id);
104  }
105
106  Buffer* GetBuffer(GLuint service_id) {
107    return group_->buffer_manager()->GetBuffer(service_id);
108  }
109
110  Framebuffer* GetFramebuffer(GLuint service_id) {
111    return group_->framebuffer_manager()->GetFramebuffer(service_id);
112  }
113
114  Renderbuffer* GetRenderbuffer(
115      GLuint service_id) {
116    return group_->renderbuffer_manager()->GetRenderbuffer(service_id);
117  }
118
119  TextureRef* GetTexture(GLuint client_id) {
120    return group_->texture_manager()->GetTexture(client_id);
121  }
122
123  Shader* GetShader(GLuint client_id) {
124    return group_->shader_manager()->GetShader(client_id);
125  }
126
127  Program* GetProgram(GLuint client_id) {
128    return group_->program_manager()->GetProgram(client_id);
129  }
130
131  QueryManager::Query* GetQueryInfo(GLuint client_id) {
132    return decoder_->GetQueryManager()->GetQuery(client_id);
133  }
134
135  // This name doesn't match the underlying function, but doing it this way
136  // prevents the need to special-case the unit test generation
137  VertexAttribManager* GetVertexArrayInfo(GLuint client_id) {
138    return decoder_->GetVertexArrayManager()->GetVertexAttribManager(client_id);
139  }
140
141  ProgramManager* program_manager() {
142    return group_->program_manager();
143  }
144
145  void DoCreateProgram(GLuint client_id, GLuint service_id);
146  void DoCreateShader(GLenum shader_type, GLuint client_id, GLuint service_id);
147
148  void SetBucketAsCString(uint32 bucket_id, const char* str);
149
150  void set_memory_tracker(MemoryTracker* memory_tracker) {
151    memory_tracker_ = memory_tracker;
152  }
153
154  struct InitState {
155    InitState();
156
157    std::string extensions;
158    std::string gl_version;
159    bool has_alpha;
160    bool has_depth;
161    bool has_stencil;
162    bool request_alpha;
163    bool request_depth;
164    bool request_stencil;
165    bool bind_generates_resource;
166    bool lose_context_when_out_of_memory;
167    bool use_native_vao;  // default is true.
168  };
169
170  void InitDecoder(const InitState& init);
171  void InitDecoderWithCommandLine(const InitState& init,
172                                  const base::CommandLine* command_line);
173
174  void ResetDecoder();
175
176  const ContextGroup& group() const {
177    return *group_.get();
178  }
179
180  ::testing::StrictMock< ::gfx::MockGLInterface>* GetGLMock() const {
181    return gl_.get();
182  }
183
184  GLES2Decoder* GetDecoder() const {
185    return decoder_.get();
186  }
187
188  typedef TestHelper::AttribInfo AttribInfo;
189  typedef TestHelper::UniformInfo UniformInfo;
190
191  void SetupShader(
192      AttribInfo* attribs, size_t num_attribs,
193      UniformInfo* uniforms, size_t num_uniforms,
194      GLuint client_id, GLuint service_id,
195      GLuint vertex_shader_client_id, GLuint vertex_shader_service_id,
196      GLuint fragment_shader_client_id, GLuint fragment_shader_service_id);
197
198  void SetupInitCapabilitiesExpectations();
199  void SetupInitStateExpectations();
200  void ExpectEnableDisable(GLenum cap, bool enable);
201
202  // Setups up a shader for testing glUniform.
203  void SetupShaderForUniform(GLenum uniform_type);
204  void SetupDefaultProgram();
205  void SetupCubemapProgram();
206  void SetupSamplerExternalProgram();
207  void SetupTexture();
208
209  // Note that the error is returned as GLint instead of GLenum.
210  // This is because there is a mismatch in the types of GLenum and
211  // the error values GL_NO_ERROR, GL_INVALID_ENUM, etc. GLenum is
212  // typedef'd as unsigned int while the error values are defined as
213  // integers. This is problematic for template functions such as
214  // EXPECT_EQ that expect both types to be the same.
215  GLint GetGLError();
216
217  void DoBindBuffer(GLenum target, GLuint client_id, GLuint service_id);
218  void DoBindFramebuffer(GLenum target, GLuint client_id, GLuint service_id);
219  void DoBindRenderbuffer(GLenum target, GLuint client_id, GLuint service_id);
220  void DoBindTexture(GLenum target, GLuint client_id, GLuint service_id);
221  void DoBindVertexArrayOES(GLuint client_id, GLuint service_id);
222
223  bool DoIsBuffer(GLuint client_id);
224  bool DoIsFramebuffer(GLuint client_id);
225  bool DoIsProgram(GLuint client_id);
226  bool DoIsRenderbuffer(GLuint client_id);
227  bool DoIsShader(GLuint client_id);
228  bool DoIsTexture(GLuint client_id);
229
230  void DoDeleteBuffer(GLuint client_id, GLuint service_id);
231  void DoDeleteFramebuffer(
232      GLuint client_id, GLuint service_id,
233      bool reset_draw, GLenum draw_target, GLuint draw_id,
234      bool reset_read, GLenum read_target, GLuint read_id);
235  void DoDeleteProgram(GLuint client_id, GLuint service_id);
236  void DoDeleteRenderbuffer(GLuint client_id, GLuint service_id);
237  void DoDeleteShader(GLuint client_id, GLuint service_id);
238  void DoDeleteTexture(GLuint client_id, GLuint service_id);
239
240  void DoCompressedTexImage2D(
241      GLenum target, GLint level, GLenum format,
242      GLsizei width, GLsizei height, GLint border,
243      GLsizei size, uint32 bucket_id);
244  void DoTexImage2D(
245      GLenum target, GLint level, GLenum internal_format,
246      GLsizei width, GLsizei height, GLint border,
247      GLenum format, GLenum type,
248      uint32 shared_memory_id, uint32 shared_memory_offset);
249  void DoTexImage2DConvertInternalFormat(
250      GLenum target, GLint level, GLenum requested_internal_format,
251      GLsizei width, GLsizei height, GLint border,
252      GLenum format, GLenum type,
253      uint32 shared_memory_id, uint32 shared_memory_offset,
254      GLenum expected_internal_format);
255  void DoRenderbufferStorage(
256      GLenum target, GLenum internal_format, GLenum actual_format,
257      GLsizei width, GLsizei height, GLenum error);
258  void DoFramebufferRenderbuffer(
259      GLenum target,
260      GLenum attachment,
261      GLenum renderbuffer_target,
262      GLuint renderbuffer_client_id,
263      GLuint renderbuffer_service_id,
264      GLenum error);
265  void DoFramebufferTexture2D(
266      GLenum target, GLenum attachment, GLenum tex_target,
267      GLuint texture_client_id, GLuint texture_service_id,
268      GLint level, GLenum error);
269  void DoVertexAttribPointer(
270      GLuint index, GLint size, GLenum type, GLsizei stride, GLuint offset);
271  void DoVertexAttribDivisorANGLE(GLuint index, GLuint divisor);
272
273  void DoEnableDisable(GLenum cap, bool enable);
274
275  void DoEnableVertexAttribArray(GLint index);
276
277  void DoBufferData(GLenum target, GLsizei size);
278
279  void DoBufferSubData(
280      GLenum target, GLint offset, GLsizei size, const void* data);
281
282  void SetupVertexBuffer();
283  void SetupAllNeededVertexBuffers();
284
285  void SetupIndexBuffer();
286
287  void DeleteVertexBuffer();
288
289  void DeleteIndexBuffer();
290
291  void SetupClearTextureExpectations(
292      GLuint service_id,
293      GLuint old_service_id,
294      GLenum bind_target,
295      GLenum target,
296      GLint level,
297      GLenum internal_format,
298      GLenum format,
299      GLenum type,
300      GLsizei width,
301      GLsizei height);
302
303  void SetupExpectationsForRestoreClearState(
304      GLclampf restore_red,
305      GLclampf restore_green,
306      GLclampf restore_blue,
307      GLclampf restore_alpha,
308      GLuint restore_stencil,
309      GLclampf restore_depth,
310      bool restore_scissor_test);
311
312  void SetupExpectationsForFramebufferClearing(
313      GLenum target,
314      GLuint clear_bits,
315      GLclampf restore_red,
316      GLclampf restore_green,
317      GLclampf restore_blue,
318      GLclampf restore_alpha,
319      GLuint restore_stencil,
320      GLclampf restore_depth,
321      bool restore_scissor_test);
322
323  void SetupExpectationsForFramebufferClearingMulti(
324      GLuint read_framebuffer_service_id,
325      GLuint draw_framebuffer_service_id,
326      GLenum target,
327      GLuint clear_bits,
328      GLclampf restore_red,
329      GLclampf restore_green,
330      GLclampf restore_blue,
331      GLclampf restore_alpha,
332      GLuint restore_stencil,
333      GLclampf restore_depth,
334      bool restore_scissor_test);
335
336  void SetupExpectationsForDepthMask(bool mask);
337  void SetupExpectationsForEnableDisable(GLenum cap, bool enable);
338  void SetupExpectationsForColorMask(bool red,
339                                     bool green,
340                                     bool blue,
341                                     bool alpha);
342
343  void SetupExpectationsForApplyingDirtyState(
344      bool framebuffer_is_rgb,
345      bool framebuffer_has_depth,
346      bool framebuffer_has_stencil,
347      GLuint color_bits,  // NOTE! bits are 0x1000, 0x0100, 0x0010, and 0x0001
348      bool depth_mask,
349      bool depth_enabled,
350      GLuint front_stencil_mask,
351      GLuint back_stencil_mask,
352      bool stencil_enabled);
353
354  void SetupExpectationsForApplyingDefaultDirtyState();
355
356  void AddExpectationsForSimulatedAttrib0WithError(
357      GLsizei num_vertices, GLuint buffer_id, GLenum error);
358
359  void AddExpectationsForSimulatedAttrib0(
360      GLsizei num_vertices, GLuint buffer_id);
361
362  void AddExpectationsForGenVertexArraysOES();
363  void AddExpectationsForDeleteVertexArraysOES();
364  void AddExpectationsForDeleteBoundVertexArraysOES();
365  void AddExpectationsForBindVertexArrayOES();
366  void AddExpectationsForRestoreAttribState(GLuint attrib);
367
368  GLvoid* BufferOffset(unsigned i) {
369    return static_cast<int8 *>(NULL)+(i);
370  }
371
372  template <typename Command, typename Result>
373  bool IsObjectHelper(GLuint client_id) {
374    Result* result = static_cast<Result*>(shared_memory_address_);
375    Command cmd;
376    cmd.Init(client_id, kSharedMemoryId, kSharedMemoryOffset);
377    EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
378    bool isObject = static_cast<bool>(*result);
379    EXPECT_EQ(GL_NO_ERROR, GetGLError());
380    return isObject;
381  }
382
383 protected:
384  static const int kBackBufferWidth = 128;
385  static const int kBackBufferHeight = 64;
386
387  static const GLint kMaxTextureSize = 2048;
388  static const GLint kMaxCubeMapTextureSize = 256;
389  static const GLint kNumVertexAttribs = 16;
390  static const GLint kNumTextureUnits = 8;
391  static const GLint kMaxTextureImageUnits = 8;
392  static const GLint kMaxVertexTextureImageUnits = 2;
393  static const GLint kMaxFragmentUniformVectors = 16;
394  static const GLint kMaxVaryingVectors = 8;
395  static const GLint kMaxVertexUniformVectors = 128;
396  static const GLint kMaxViewportWidth = 8192;
397  static const GLint kMaxViewportHeight = 8192;
398
399  static const GLint kViewportX = 0;
400  static const GLint kViewportY = 0;
401  static const GLint kViewportWidth = kBackBufferWidth;
402  static const GLint kViewportHeight = kBackBufferHeight;
403
404  static const GLuint kServiceAttrib0BufferId = 801;
405  static const GLuint kServiceFixedAttribBufferId = 802;
406
407  static const GLuint kServiceBufferId = 301;
408  static const GLuint kServiceFramebufferId = 302;
409  static const GLuint kServiceRenderbufferId = 303;
410  static const GLuint kServiceTextureId = 304;
411  static const GLuint kServiceProgramId = 305;
412  static const GLuint kServiceShaderId = 306;
413  static const GLuint kServiceElementBufferId = 308;
414  static const GLuint kServiceQueryId = 309;
415  static const GLuint kServiceVertexArrayId = 310;
416
417  static const int32 kSharedMemoryId = 401;
418  static const size_t kSharedBufferSize = 2048;
419  static const uint32 kSharedMemoryOffset = 132;
420  static const int32 kInvalidSharedMemoryId = 402;
421  static const uint32 kInvalidSharedMemoryOffset = kSharedBufferSize + 1;
422  static const uint32 kInitialResult = 0xBDBDBDBDu;
423  static const uint8 kInitialMemoryValue = 0xBDu;
424
425  static const uint32 kNewClientId = 501;
426  static const uint32 kNewServiceId = 502;
427  static const uint32 kInvalidClientId = 601;
428
429  static const GLuint kServiceVertexShaderId = 321;
430  static const GLuint kServiceFragmentShaderId = 322;
431
432  static const GLuint kServiceCopyTextureChromiumShaderId = 701;
433  static const GLuint kServiceCopyTextureChromiumProgramId = 721;
434
435  static const GLuint kServiceCopyTextureChromiumTextureBufferId = 751;
436  static const GLuint kServiceCopyTextureChromiumVertexBufferId = 752;
437  static const GLuint kServiceCopyTextureChromiumFBOId = 753;
438  static const GLuint kServiceCopyTextureChromiumPositionAttrib = 761;
439  static const GLuint kServiceCopyTextureChromiumTexAttrib = 762;
440  static const GLuint kServiceCopyTextureChromiumSamplerLocation = 763;
441
442  static const GLsizei kNumVertices = 100;
443  static const GLsizei kNumIndices = 10;
444  static const int kValidIndexRangeStart = 1;
445  static const int kValidIndexRangeCount = 7;
446  static const int kInvalidIndexRangeStart = 0;
447  static const int kInvalidIndexRangeCount = 7;
448  static const int kOutOfRangeIndexRangeEnd = 10;
449  static const GLuint kMaxValidIndex = 7;
450
451  static const GLint kMaxAttribLength = 10;
452  static const char* kAttrib1Name;
453  static const char* kAttrib2Name;
454  static const char* kAttrib3Name;
455  static const GLint kAttrib1Size = 1;
456  static const GLint kAttrib2Size = 1;
457  static const GLint kAttrib3Size = 1;
458  static const GLint kAttrib1Location = 0;
459  static const GLint kAttrib2Location = 1;
460  static const GLint kAttrib3Location = 2;
461  static const GLenum kAttrib1Type = GL_FLOAT_VEC4;
462  static const GLenum kAttrib2Type = GL_FLOAT_VEC2;
463  static const GLenum kAttrib3Type = GL_FLOAT_VEC3;
464  static const GLint kInvalidAttribLocation = 30;
465  static const GLint kBadAttribIndex = kNumVertexAttribs;
466
467  static const GLint kMaxUniformLength = 12;
468  static const char* kUniform1Name;
469  static const char* kUniform2Name;
470  static const char* kUniform3Name;
471  static const GLint kUniform1Size = 1;
472  static const GLint kUniform2Size = 3;
473  static const GLint kUniform3Size = 2;
474  static const GLint kUniform1RealLocation = 3;
475  static const GLint kUniform2RealLocation = 10;
476  static const GLint kUniform2ElementRealLocation = 12;
477  static const GLint kUniform3RealLocation = 20;
478  static const GLint kUniform1FakeLocation = 0;               // These are
479  static const GLint kUniform2FakeLocation = 1;               // hardcoded
480  static const GLint kUniform2ElementFakeLocation = 0x10001;  // to match
481  static const GLint kUniform3FakeLocation = 2;               // ProgramManager.
482  static const GLint kUniform1DesiredLocation = -1;
483  static const GLint kUniform2DesiredLocation = -1;
484  static const GLint kUniform3DesiredLocation = -1;
485  static const GLenum kUniform1Type = GL_SAMPLER_2D;
486  static const GLenum kUniform2Type = GL_INT_VEC2;
487  static const GLenum kUniform3Type = GL_FLOAT_VEC3;
488  static const GLenum kUniformSamplerExternalType = GL_SAMPLER_EXTERNAL_OES;
489  static const GLenum kUniformCubemapType = GL_SAMPLER_CUBE;
490  static const GLint kInvalidUniformLocation = 30;
491  static const GLint kBadUniformIndex = 1000;
492
493  // Use StrictMock to make 100% sure we know how GL will be called.
494  scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
495  scoped_refptr<gfx::GLSurfaceStub> surface_;
496  scoped_refptr<gfx::GLContextStubWithExtensions> context_;
497  scoped_ptr<MockGLES2Decoder> mock_decoder_;
498  scoped_ptr<GLES2Decoder> decoder_;
499  MemoryTracker* memory_tracker_;
500
501  GLuint client_buffer_id_;
502  GLuint client_framebuffer_id_;
503  GLuint client_program_id_;
504  GLuint client_renderbuffer_id_;
505  GLuint client_shader_id_;
506  GLuint client_texture_id_;
507  GLuint client_element_buffer_id_;
508  GLuint client_vertex_shader_id_;
509  GLuint client_fragment_shader_id_;
510  GLuint client_query_id_;
511  GLuint client_vertexarray_id_;
512
513  uint32 shared_memory_id_;
514  uint32 shared_memory_offset_;
515  void* shared_memory_address_;
516  void* shared_memory_base_;
517
518  int8 immediate_buffer_[256];
519
520  const bool ignore_cached_state_for_test_;
521  bool cached_color_mask_red_;
522  bool cached_color_mask_green_;
523  bool cached_color_mask_blue_;
524  bool cached_color_mask_alpha_;
525  bool cached_depth_mask_;
526  uint32 cached_stencil_front_mask_;
527  uint32 cached_stencil_back_mask_;
528
529  struct EnableFlags {
530    EnableFlags();
531    bool cached_blend;
532    bool cached_cull_face;
533    bool cached_depth_test;
534    bool cached_dither;
535    bool cached_polygon_offset_fill;
536    bool cached_sample_alpha_to_coverage;
537    bool cached_sample_coverage;
538    bool cached_scissor_test;
539    bool cached_stencil_test;
540  };
541
542  EnableFlags enable_flags_;
543
544 private:
545  class MockCommandBufferEngine : public CommandBufferEngine {
546   public:
547    MockCommandBufferEngine();
548
549    virtual ~MockCommandBufferEngine();
550
551    virtual scoped_refptr<gpu::Buffer> GetSharedMemoryBuffer(int32 shm_id)
552        OVERRIDE;
553
554    void ClearSharedMemory() {
555      memset(valid_buffer_->memory(), kInitialMemoryValue, kSharedBufferSize);
556    }
557
558    virtual void set_token(int32 token) OVERRIDE;
559
560    virtual bool SetGetBuffer(int32 /* transfer_buffer_id */) OVERRIDE;
561
562    // Overridden from CommandBufferEngine.
563    virtual bool SetGetOffset(int32 offset) OVERRIDE;
564
565    // Overridden from CommandBufferEngine.
566    virtual int32 GetGetOffset() OVERRIDE;
567
568   private:
569    scoped_refptr<gpu::Buffer> valid_buffer_;
570    scoped_refptr<gpu::Buffer> invalid_buffer_;
571  };
572
573  // MockGLStates is used to track GL states and emulate driver
574  // behaviors on top of MockGLInterface.
575  class MockGLStates {
576   public:
577    MockGLStates()
578        : bound_array_buffer_object_(0),
579          bound_vertex_array_object_(0) {
580    }
581
582    ~MockGLStates() {
583    }
584
585    void OnBindArrayBuffer(GLuint id) {
586      bound_array_buffer_object_ = id;
587    }
588
589    void OnBindVertexArrayOES(GLuint id) {
590      bound_vertex_array_object_ = id;
591    }
592
593    void OnVertexAttribNullPointer() {
594      // When a vertex array object is bound, some drivers (AMD Linux,
595      // Qualcomm, etc.) have a bug where it incorrectly generates an
596      // GL_INVALID_OPERATION on glVertexAttribPointer() if pointer
597      // is NULL, no buffer is bound on GL_ARRAY_BUFFER.
598      // Make sure we don't trigger this bug.
599      if (bound_vertex_array_object_ != 0)
600        EXPECT_TRUE(bound_array_buffer_object_ != 0);
601    }
602
603   private:
604    GLuint bound_array_buffer_object_;
605    GLuint bound_vertex_array_object_;
606  };  // class MockGLStates
607
608  void AddExpectationsForVertexAttribManager();
609  void SetupMockGLBehaviors();
610
611  scoped_ptr< ::testing::StrictMock<MockCommandBufferEngine> > engine_;
612  scoped_refptr<ContextGroup> group_;
613  MockGLStates gl_states_;
614};
615
616class GLES2DecoderWithShaderTestBase : public GLES2DecoderTestBase {
617 public:
618  GLES2DecoderWithShaderTestBase()
619      : GLES2DecoderTestBase() {
620  }
621
622 protected:
623  virtual void SetUp() OVERRIDE;
624  virtual void TearDown() OVERRIDE;
625
626};
627
628// SpecializedSetup specializations that are needed in multiple unittest files.
629template <>
630void GLES2DecoderTestBase::SpecializedSetup<cmds::LinkProgram, 0>(bool valid);
631
632}  // namespace gles2
633}  // namespace gpu
634
635#endif  // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_
636