Infobar material design refresh: bg color
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_decoder_unittest_1.cc
blob95ada5dcf5c665ec2daed54a962eddd1008b6391
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 class GLES2DecoderTest1 : public GLES2DecoderTestBase {
32 public:
33 GLES2DecoderTest1() { }
36 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest1, ::testing::Bool());
38 template <>
39 void GLES2DecoderTestBase::SpecializedSetup<cmds::GenerateMipmap, 0>(
40 bool valid) {
41 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
42 DoTexImage2D(
43 GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
44 kSharedMemoryId, kSharedMemoryOffset);
45 if (valid) {
46 EXPECT_CALL(*gl_, GetError())
47 .WillOnce(Return(GL_NO_ERROR))
48 .WillOnce(Return(GL_NO_ERROR))
49 .RetiresOnSaturation();
53 template <>
54 void GLES2DecoderTestBase::SpecializedSetup<cmds::CheckFramebufferStatus, 0>(
55 bool /* valid */) {
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);
68 template <>
69 void GLES2DecoderTestBase::SpecializedSetup<cmds::Clear, 0>(bool valid) {
70 if (valid) {
71 SetupExpectationsForApplyingDefaultDirtyState();
75 template <>
76 void GLES2DecoderTestBase::SpecializedSetup<cmds::ColorMask, 0>(
77 bool /* valid */) {
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);
84 template <>
85 void GLES2DecoderTestBase::SpecializedSetup<cmds::CopyTexImage2D, 0>(
86 bool valid) {
87 if (valid) {
88 EXPECT_CALL(*gl_, GetError())
89 .WillOnce(Return(GL_NO_ERROR))
90 .WillOnce(Return(GL_NO_ERROR))
91 .RetiresOnSaturation();
95 template <>
96 void GLES2DecoderTestBase::SpecializedSetup<cmds::CopyTexSubImage2D, 0>(
97 bool valid) {
98 if (valid) {
99 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
100 DoTexImage2D(
101 GL_TEXTURE_2D, 2, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
102 kSharedMemoryId, kSharedMemoryOffset);
106 template <>
107 void GLES2DecoderTestBase::SpecializedSetup<cmds::DetachShader, 0>(bool valid) {
108 if (valid) {
109 EXPECT_CALL(*gl_,
110 AttachShader(kServiceProgramId, kServiceShaderId))
111 .Times(1)
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));
119 template <>
120 void GLES2DecoderTestBase::SpecializedSetup<cmds::FramebufferRenderbuffer, 0>(
121 bool valid) {
122 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
123 kServiceFramebufferId);
124 if (valid) {
125 EXPECT_CALL(*gl_, GetError())
126 .WillOnce(Return(GL_NO_ERROR))
127 .WillOnce(Return(GL_NO_ERROR))
128 .RetiresOnSaturation();
132 template <>
133 void GLES2DecoderTestBase::SpecializedSetup<cmds::FramebufferTexture2D, 0>(
134 bool valid) {
135 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
136 kServiceFramebufferId);
137 if (valid) {
138 EXPECT_CALL(*gl_, GetError())
139 .WillOnce(Return(GL_NO_ERROR))
140 .WillOnce(Return(GL_NO_ERROR))
141 .RetiresOnSaturation();
145 template <>
146 void GLES2DecoderTestBase::SpecializedSetup<
147 cmds::GetBufferParameteri64v, 0>(bool /* valid */) {
148 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
151 template <>
152 void GLES2DecoderTestBase::SpecializedSetup<
153 cmds::GetBufferParameteriv, 0>(bool /* valid */) {
154 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
157 template <>
158 void GLES2DecoderTestBase::SpecializedSetup<
159 cmds::GetFramebufferAttachmentParameteriv, 0>(bool /* valid */) {
160 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
161 kServiceFramebufferId);
164 template <>
165 void GLES2DecoderTestBase::SpecializedSetup<cmds::GetProgramiv, 0>(
166 bool valid) {
167 if (valid) {
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"
181 } // namespace gles2
182 } // namespace gpu