Elim cr-checkbox
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_decoder_unittest_3.cc
blob93dea22f49484a7d9de634ca85ff6a95dea4cee1
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;
17 using ::testing::_;
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;
27 namespace gpu {
28 namespace gles2 {
30 using namespace cmds;
32 class GLES2DecoderTest3 : public GLES2DecoderTestBase {
33 public:
34 GLES2DecoderTest3() { }
37 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest3, ::testing::Bool());
39 template <>
40 void GLES2DecoderTestBase::SpecializedSetup<cmds::UniformMatrix3fvImmediate, 0>(
41 bool /* valid */) {
42 SetupShaderForUniform(GL_FLOAT_MAT3);
45 template <>
46 void GLES2DecoderTestBase::SpecializedSetup<cmds::UniformMatrix4fvImmediate, 0>(
47 bool /* valid */) {
48 SetupShaderForUniform(GL_FLOAT_MAT4);
51 template <>
52 void GLES2DecoderTestBase::SpecializedSetup<
53 cmds::UniformMatrix2x4fvImmediate, 0>(bool /* valid */) {
54 SetupShaderForUniform(GL_FLOAT_MAT2x4);
57 template <>
58 void GLES2DecoderTestBase::SpecializedSetup<
59 cmds::UniformMatrix3x2fvImmediate, 0>(bool /* valid */) {
60 SetupShaderForUniform(GL_FLOAT_MAT3x2);
63 template <>
64 void GLES2DecoderTestBase::SpecializedSetup<
65 cmds::UniformMatrix3x4fvImmediate, 0>(bool /* valid */) {
66 SetupShaderForUniform(GL_FLOAT_MAT3x4);
69 template <>
70 void GLES2DecoderTestBase::SpecializedSetup<
71 cmds::UniformMatrix4x2fvImmediate, 0>(bool /* valid */) {
72 SetupShaderForUniform(GL_FLOAT_MAT4x2);
75 template <>
76 void GLES2DecoderTestBase::SpecializedSetup<
77 cmds::UniformMatrix4x3fvImmediate, 0>(bool /* valid */) {
78 SetupShaderForUniform(GL_FLOAT_MAT4x3);
81 template <>
82 void GLES2DecoderTestBase::SpecializedSetup<cmds::UseProgram, 0>(
83 bool /* valid */) {
84 // Needs the same setup as LinkProgram.
85 SpecializedSetup<cmds::LinkProgram, 0>(false);
87 EXPECT_CALL(*gl_, LinkProgram(kServiceProgramId))
88 .Times(1)
89 .RetiresOnSaturation();
91 cmds::LinkProgram link_cmd;
92 link_cmd.Init(client_program_id_);
93 EXPECT_EQ(error::kNoError, ExecuteCmd(link_cmd));
96 template <>
97 void GLES2DecoderTestBase::SpecializedSetup<cmds::ValidateProgram, 0>(
98 bool /* valid */) {
99 // Needs the same setup as LinkProgram.
100 SpecializedSetup<cmds::LinkProgram, 0>(false);
102 EXPECT_CALL(*gl_, LinkProgram(kServiceProgramId))
103 .Times(1)
104 .RetiresOnSaturation();
106 cmds::LinkProgram link_cmd;
107 link_cmd.Init(client_program_id_);
108 EXPECT_EQ(error::kNoError, ExecuteCmd(link_cmd));
110 EXPECT_CALL(*gl_,
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;
133 end_cmd.Init();
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));
149 end_cmd.Init();
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"
156 } // namespace gles2
157 } // namespace gpu