Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_decoder_unittest_1.cc
blob3fb52f9bc13bdda84a293bbf157412b03bd49095
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;
18 using ::testing::_;
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;
28 namespace gpu {
29 namespace gles2 {
31 namespace {
32 void ShaderCacheCb(const std::string& key, const std::string& shader) {
34 } // namespace
36 class GLES2DecoderTest1 : public GLES2DecoderTestBase {
37 public:
38 GLES2DecoderTest1() { }
41 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest1, ::testing::Bool());
43 template <>
44 void GLES2DecoderTestBase::SpecializedSetup<cmds::GenerateMipmap, 0>(
45 bool valid) {
46 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
47 DoTexImage2D(
48 GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
49 kSharedMemoryId, kSharedMemoryOffset);
50 if (valid) {
51 EXPECT_CALL(*gl_, GetError())
52 .WillOnce(Return(GL_NO_ERROR))
53 .WillOnce(Return(GL_NO_ERROR))
54 .RetiresOnSaturation();
58 template <>
59 void GLES2DecoderTestBase::SpecializedSetup<cmds::CheckFramebufferStatus, 0>(
60 bool /* valid */) {
61 // Give it a valid framebuffer.
62 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
63 kServiceRenderbufferId);
64 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
65 kServiceFramebufferId);
66 DoRenderbufferStorage(
67 GL_RENDERBUFFER, GL_RGBA4, GL_RGBA, 1, 1, GL_NO_ERROR);
68 DoFramebufferRenderbuffer(
69 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
70 client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR);
73 template <>
74 void GLES2DecoderTestBase::SpecializedSetup<cmds::Clear, 0>(bool valid) {
75 if (valid) {
76 SetupExpectationsForApplyingDefaultDirtyState();
80 template <>
81 void GLES2DecoderTestBase::SpecializedSetup<cmds::ColorMask, 0>(
82 bool /* valid */) {
83 // We bind a framebuffer color the colormask test since the framebuffer
84 // will be considered RGB.
85 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
86 kServiceFramebufferId);
89 template <>
90 void GLES2DecoderTestBase::SpecializedSetup<cmds::CopyTexImage2D, 0>(
91 bool valid) {
92 if (valid) {
93 EXPECT_CALL(*gl_, GetError())
94 .WillOnce(Return(GL_NO_ERROR))
95 .WillOnce(Return(GL_NO_ERROR))
96 .RetiresOnSaturation();
100 template <>
101 void GLES2DecoderTestBase::SpecializedSetup<cmds::CopyTexSubImage2D, 0>(
102 bool valid) {
103 if (valid) {
104 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
105 DoTexImage2D(
106 GL_TEXTURE_2D, 2, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
107 kSharedMemoryId, kSharedMemoryOffset);
111 template <>
112 void GLES2DecoderTestBase::SpecializedSetup<cmds::DetachShader, 0>(bool valid) {
113 if (valid) {
114 EXPECT_CALL(*gl_,
115 AttachShader(kServiceProgramId, kServiceShaderId))
116 .Times(1)
117 .RetiresOnSaturation();
118 cmds::AttachShader attach_cmd;
119 attach_cmd.Init(client_program_id_, client_shader_id_);
120 EXPECT_EQ(error::kNoError, ExecuteCmd(attach_cmd));
124 template <>
125 void GLES2DecoderTestBase::SpecializedSetup<cmds::FramebufferRenderbuffer, 0>(
126 bool valid) {
127 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
128 kServiceFramebufferId);
129 if (valid) {
130 EXPECT_CALL(*gl_, GetError())
131 .WillOnce(Return(GL_NO_ERROR))
132 .WillOnce(Return(GL_NO_ERROR))
133 .RetiresOnSaturation();
137 template <>
138 void GLES2DecoderTestBase::SpecializedSetup<cmds::FramebufferTexture2D, 0>(
139 bool valid) {
140 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
141 kServiceFramebufferId);
142 if (valid) {
143 EXPECT_CALL(*gl_, GetError())
144 .WillOnce(Return(GL_NO_ERROR))
145 .WillOnce(Return(GL_NO_ERROR))
146 .RetiresOnSaturation();
150 template <>
151 void GLES2DecoderTestBase::SpecializedSetup<
152 cmds::GetBufferParameteriv, 0>(bool /* valid */) {
153 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
156 template <>
157 void GLES2DecoderTestBase::SpecializedSetup<
158 cmds::GetFramebufferAttachmentParameteriv, 0>(bool /* valid */) {
159 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
160 kServiceFramebufferId);
163 template <>
164 void GLES2DecoderTestBase::SpecializedSetup<cmds::GetProgramiv, 0>(
165 bool valid) {
166 if (valid) {
167 // GetProgramiv calls ClearGLError then GetError to make sure
168 // it actually got a value so it can report correctly to the client.
169 EXPECT_CALL(*gl_, GetError())
170 .WillOnce(Return(GL_NO_ERROR))
171 .RetiresOnSaturation();
172 EXPECT_CALL(*gl_, GetError())
173 .WillOnce(Return(GL_NO_ERROR))
174 .RetiresOnSaturation();
178 template <>
179 void GLES2DecoderTestBase::SpecializedSetup<cmds::GetProgramInfoLog, 0>(
180 bool /* valid */) {
181 const GLuint kClientVertexShaderId = 5001;
182 const GLuint kServiceVertexShaderId = 6001;
183 const GLuint kClientFragmentShaderId = 5002;
184 const GLuint kServiceFragmentShaderId = 6002;
185 const char* log = "hello"; // Matches auto-generated unit test.
186 DoCreateShader(
187 GL_VERTEX_SHADER, kClientVertexShaderId, kServiceVertexShaderId);
188 DoCreateShader(
189 GL_FRAGMENT_SHADER, kClientFragmentShaderId, kServiceFragmentShaderId);
191 TestHelper::SetShaderStates(
192 gl_.get(), GetShader(kClientVertexShaderId), true);
193 TestHelper::SetShaderStates(
194 gl_.get(), GetShader(kClientFragmentShaderId), true);
196 InSequence dummy;
197 EXPECT_CALL(*gl_,
198 AttachShader(kServiceProgramId, kServiceVertexShaderId))
199 .Times(1)
200 .RetiresOnSaturation();
201 EXPECT_CALL(*gl_,
202 AttachShader(kServiceProgramId, kServiceFragmentShaderId))
203 .Times(1)
204 .RetiresOnSaturation();
205 EXPECT_CALL(*gl_, LinkProgram(kServiceProgramId))
206 .Times(1)
207 .RetiresOnSaturation();
208 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
209 .WillOnce(SetArgumentPointee<2>(1));
210 EXPECT_CALL(*gl_,
211 GetProgramiv(kServiceProgramId, GL_INFO_LOG_LENGTH, _))
212 .WillOnce(SetArgumentPointee<2>(strlen(log) + 1))
213 .RetiresOnSaturation();
214 EXPECT_CALL(*gl_,
215 GetProgramInfoLog(kServiceProgramId, strlen(log) + 1, _, _))
216 .WillOnce(DoAll(
217 SetArgumentPointee<2>(strlen(log)),
218 SetArrayArgument<3>(log, log + strlen(log) + 1)))
219 .RetiresOnSaturation();
220 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_ACTIVE_ATTRIBUTES, _))
221 .WillOnce(SetArgumentPointee<2>(0));
222 EXPECT_CALL(
223 *gl_,
224 GetProgramiv(kServiceProgramId, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, _))
225 .WillOnce(SetArgumentPointee<2>(0));
226 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORMS, _))
227 .WillOnce(SetArgumentPointee<2>(0));
228 EXPECT_CALL(
229 *gl_,
230 GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORM_MAX_LENGTH, _))
231 .WillOnce(SetArgumentPointee<2>(0));
233 Program* program = GetProgram(client_program_id_);
234 ASSERT_TRUE(program != NULL);
236 cmds::AttachShader attach_cmd;
237 attach_cmd.Init(client_program_id_, kClientVertexShaderId);
238 EXPECT_EQ(error::kNoError, ExecuteCmd(attach_cmd));
240 attach_cmd.Init(client_program_id_, kClientFragmentShaderId);
241 EXPECT_EQ(error::kNoError, ExecuteCmd(attach_cmd));
243 program->Link(NULL, Program::kCountOnlyStaticallyUsed,
244 base::Bind(&ShaderCacheCb));
247 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h"
249 } // namespace gles2
250 } // namespace gpu