1 // Copyright (c) 2011 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 "testing/gtest/include/gtest/gtest.h"
14 #include "ui/gl/gl_mock.h"
16 using ::gfx::MockGLInterface
;
18 using ::testing::DoAll
;
19 using ::testing::InSequence
;
20 using ::testing::MatcherCast
;
21 using ::testing::Pointee
;
22 using ::testing::Return
;
23 using ::testing::SetArrayArgument
;
24 using ::testing::SetArgumentPointee
;
25 using ::testing::StrEq
;
32 class GLES2DecoderTest3
: public GLES2DecoderTestBase
{
34 GLES2DecoderTest3() { }
37 INSTANTIATE_TEST_CASE_P(Service
, GLES2DecoderTest3
, ::testing::Bool());
40 void GLES2DecoderTestBase::SpecializedSetup
<cmds::UniformMatrix3fvImmediate
, 0>(
42 SetupShaderForUniform(GL_FLOAT_MAT3
);
46 void GLES2DecoderTestBase::SpecializedSetup
<cmds::UniformMatrix4fvImmediate
, 0>(
48 SetupShaderForUniform(GL_FLOAT_MAT4
);
52 void GLES2DecoderTestBase::SpecializedSetup
<
53 cmds::UniformMatrix2x4fvImmediate
, 0>(bool /* valid */) {
54 SetupShaderForUniform(GL_FLOAT_MAT2x4
);
58 void GLES2DecoderTestBase::SpecializedSetup
<
59 cmds::UniformMatrix3x2fvImmediate
, 0>(bool /* valid */) {
60 SetupShaderForUniform(GL_FLOAT_MAT3x2
);
64 void GLES2DecoderTestBase::SpecializedSetup
<
65 cmds::UniformMatrix3x4fvImmediate
, 0>(bool /* valid */) {
66 SetupShaderForUniform(GL_FLOAT_MAT3x4
);
70 void GLES2DecoderTestBase::SpecializedSetup
<
71 cmds::UniformMatrix4x2fvImmediate
, 0>(bool /* valid */) {
72 SetupShaderForUniform(GL_FLOAT_MAT4x2
);
76 void GLES2DecoderTestBase::SpecializedSetup
<
77 cmds::UniformMatrix4x3fvImmediate
, 0>(bool /* valid */) {
78 SetupShaderForUniform(GL_FLOAT_MAT4x3
);
82 void GLES2DecoderTestBase::SpecializedSetup
<cmds::UseProgram
, 0>(
84 // Needs the same setup as LinkProgram.
85 SpecializedSetup
<cmds::LinkProgram
, 0>(false);
87 EXPECT_CALL(*gl_
, LinkProgram(kServiceProgramId
))
89 .RetiresOnSaturation();
91 cmds::LinkProgram link_cmd
;
92 link_cmd
.Init(client_program_id_
);
93 EXPECT_EQ(error::kNoError
, ExecuteCmd(link_cmd
));
97 void GLES2DecoderTestBase::SpecializedSetup
<cmds::ValidateProgram
, 0>(
99 // Needs the same setup as LinkProgram.
100 SpecializedSetup
<cmds::LinkProgram
, 0>(false);
102 EXPECT_CALL(*gl_
, LinkProgram(kServiceProgramId
))
104 .RetiresOnSaturation();
106 cmds::LinkProgram link_cmd
;
107 link_cmd
.Init(client_program_id_
);
108 EXPECT_EQ(error::kNoError
, ExecuteCmd(link_cmd
));
111 GetProgramiv(kServiceProgramId
, GL_INFO_LOG_LENGTH
, _
))
112 .WillOnce(SetArgumentPointee
<2>(0))
113 .RetiresOnSaturation();
116 TEST_P(GLES2DecoderTest3
, TraceBeginCHROMIUM
) {
117 const uint32 kCategoryBucketId
= 123;
118 const uint32 kNameBucketId
= 234;
120 const char kCategory
[] = "test_category";
121 const char kName
[] = "test_command";
122 SetBucketAsCString(kCategoryBucketId
, kCategory
);
123 SetBucketAsCString(kNameBucketId
, kName
);
125 TraceBeginCHROMIUM begin_cmd
;
126 begin_cmd
.Init(kCategoryBucketId
, kNameBucketId
);
127 EXPECT_EQ(error::kNoError
, ExecuteCmd(begin_cmd
));
130 TEST_P(GLES2DecoderTest3
, TraceEndCHROMIUM
) {
131 // Test end fails if no begin.
132 TraceEndCHROMIUM end_cmd
;
134 EXPECT_EQ(error::kNoError
, ExecuteCmd(end_cmd
));
135 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
137 const uint32 kCategoryBucketId
= 123;
138 const uint32 kNameBucketId
= 234;
140 const char kCategory
[] = "test_category";
141 const char kName
[] = "test_command";
142 SetBucketAsCString(kCategoryBucketId
, kCategory
);
143 SetBucketAsCString(kNameBucketId
, kName
);
145 TraceBeginCHROMIUM begin_cmd
;
146 begin_cmd
.Init(kCategoryBucketId
, kNameBucketId
);
147 EXPECT_EQ(error::kNoError
, ExecuteCmd(begin_cmd
));
150 EXPECT_EQ(error::kNoError
, ExecuteCmd(end_cmd
));
151 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
154 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h"