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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
7 #include "gpu/command_buffer/common/gles2_cmd_format.h"
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
9 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
10 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
11 #include "gpu/command_buffer/service/context_group.h"
12 #include "gpu/command_buffer/service/program_manager.h"
13 #include "gpu/command_buffer/service/test_helper.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/gl/gl_mock.h"
17 using ::gfx::MockGLInterface
;
19 using ::testing::DoAll
;
20 using ::testing::InSequence
;
21 using ::testing::MatcherCast
;
22 using ::testing::Pointee
;
23 using ::testing::Return
;
24 using ::testing::SetArrayArgument
;
25 using ::testing::SetArgumentPointee
;
26 using ::testing::StrEq
;
31 class GLES2DecoderTest1
: public GLES2DecoderTestBase
{
33 GLES2DecoderTest1() { }
36 INSTANTIATE_TEST_CASE_P(Service
, GLES2DecoderTest1
, ::testing::Bool());
39 void GLES2DecoderTestBase::SpecializedSetup
<cmds::GenerateMipmap
, 0>(
41 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
43 GL_TEXTURE_2D
, 0, GL_RGBA
, 16, 16, 0, GL_RGBA
, GL_UNSIGNED_BYTE
,
44 kSharedMemoryId
, kSharedMemoryOffset
);
46 EXPECT_CALL(*gl_
, GetError())
47 .WillOnce(Return(GL_NO_ERROR
))
48 .WillOnce(Return(GL_NO_ERROR
))
49 .RetiresOnSaturation();
54 void GLES2DecoderTestBase::SpecializedSetup
<cmds::CheckFramebufferStatus
, 0>(
56 // Give it a valid framebuffer.
57 DoBindRenderbuffer(GL_RENDERBUFFER
, client_renderbuffer_id_
,
58 kServiceRenderbufferId
);
59 DoBindFramebuffer(GL_FRAMEBUFFER
, client_framebuffer_id_
,
60 kServiceFramebufferId
);
61 DoRenderbufferStorage(
62 GL_RENDERBUFFER
, GL_RGBA4
, GL_RGBA
, 1, 1, GL_NO_ERROR
);
63 DoFramebufferRenderbuffer(
64 GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_RENDERBUFFER
,
65 client_renderbuffer_id_
, kServiceRenderbufferId
, GL_NO_ERROR
);
69 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Clear
, 0>(bool valid
) {
71 SetupExpectationsForApplyingDefaultDirtyState();
76 void GLES2DecoderTestBase::SpecializedSetup
<cmds::ColorMask
, 0>(
78 // We bind a framebuffer color the colormask test since the framebuffer
79 // will be considered RGB.
80 DoBindFramebuffer(GL_FRAMEBUFFER
, client_framebuffer_id_
,
81 kServiceFramebufferId
);
85 void GLES2DecoderTestBase::SpecializedSetup
<cmds::CopyTexImage2D
, 0>(
88 EXPECT_CALL(*gl_
, GetError())
89 .WillOnce(Return(GL_NO_ERROR
))
90 .WillOnce(Return(GL_NO_ERROR
))
91 .RetiresOnSaturation();
96 void GLES2DecoderTestBase::SpecializedSetup
<cmds::CopyTexSubImage2D
, 0>(
99 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
101 GL_TEXTURE_2D
, 2, GL_RGBA
, 16, 16, 0, GL_RGBA
, GL_UNSIGNED_BYTE
,
102 kSharedMemoryId
, kSharedMemoryOffset
);
107 void GLES2DecoderTestBase::SpecializedSetup
<cmds::DetachShader
, 0>(bool valid
) {
110 AttachShader(kServiceProgramId
, kServiceShaderId
))
112 .RetiresOnSaturation();
113 cmds::AttachShader attach_cmd
;
114 attach_cmd
.Init(client_program_id_
, client_shader_id_
);
115 EXPECT_EQ(error::kNoError
, ExecuteCmd(attach_cmd
));
120 void GLES2DecoderTestBase::SpecializedSetup
<cmds::FramebufferRenderbuffer
, 0>(
122 DoBindFramebuffer(GL_FRAMEBUFFER
, client_framebuffer_id_
,
123 kServiceFramebufferId
);
125 EXPECT_CALL(*gl_
, GetError())
126 .WillOnce(Return(GL_NO_ERROR
))
127 .WillOnce(Return(GL_NO_ERROR
))
128 .RetiresOnSaturation();
133 void GLES2DecoderTestBase::SpecializedSetup
<cmds::FramebufferTexture2D
, 0>(
135 DoBindFramebuffer(GL_FRAMEBUFFER
, client_framebuffer_id_
,
136 kServiceFramebufferId
);
138 EXPECT_CALL(*gl_
, GetError())
139 .WillOnce(Return(GL_NO_ERROR
))
140 .WillOnce(Return(GL_NO_ERROR
))
141 .RetiresOnSaturation();
146 void GLES2DecoderTestBase::SpecializedSetup
<
147 cmds::GetBufferParameteri64v
, 0>(bool /* valid */) {
148 DoBindBuffer(GL_ARRAY_BUFFER
, client_buffer_id_
, kServiceBufferId
);
152 void GLES2DecoderTestBase::SpecializedSetup
<
153 cmds::GetBufferParameteriv
, 0>(bool /* valid */) {
154 DoBindBuffer(GL_ARRAY_BUFFER
, client_buffer_id_
, kServiceBufferId
);
158 void GLES2DecoderTestBase::SpecializedSetup
<
159 cmds::GetFramebufferAttachmentParameteriv
, 0>(bool /* valid */) {
160 DoBindFramebuffer(GL_FRAMEBUFFER
, client_framebuffer_id_
,
161 kServiceFramebufferId
);
165 void GLES2DecoderTestBase::SpecializedSetup
<cmds::GetProgramiv
, 0>(
168 // GetProgramiv calls ClearGLError then GetError to make sure
169 // it actually got a value so it can report correctly to the client.
170 EXPECT_CALL(*gl_
, GetError())
171 .WillOnce(Return(GL_NO_ERROR
))
172 .RetiresOnSaturation();
173 EXPECT_CALL(*gl_
, GetError())
174 .WillOnce(Return(GL_NO_ERROR
))
175 .RetiresOnSaturation();
179 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h"