OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 12 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
13 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 13 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
14 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 14 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
15 #include "gpu/command_buffer/service/context_group.h" | 15 #include "gpu/command_buffer/service/context_group.h" |
| 16 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" |
16 #include "gpu/command_buffer/service/program_manager.h" | 17 #include "gpu/command_buffer/service/program_manager.h" |
17 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 18 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
18 #include "gpu/command_buffer/service/test_helper.h" | 19 #include "gpu/command_buffer/service/test_helper.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/gl/gl_implementation.h" | 21 #include "ui/gl/gl_implementation.h" |
21 #include "ui/gl/gl_mock.h" | 22 #include "ui/gl/gl_mock.h" |
22 | 23 |
23 using ::gfx::MockGLInterface; | 24 using ::gfx::MockGLInterface; |
24 using ::testing::_; | 25 using ::testing::_; |
25 using ::testing::DoAll; | 26 using ::testing::DoAll; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 group_ = ContextGroup::Ref(new ContextGroup(NULL, | 91 group_ = ContextGroup::Ref(new ContextGroup(NULL, |
91 NULL, | 92 NULL, |
92 NULL, | 93 NULL, |
93 bind_generates_resource)); | 94 bind_generates_resource)); |
94 | 95 |
95 InSequence sequence; | 96 InSequence sequence; |
96 | 97 |
97 TestHelper::SetupContextGroupInitExpectations(gl_.get(), | 98 TestHelper::SetupContextGroupInitExpectations(gl_.get(), |
98 DisallowedFeatures(), extensions); | 99 DisallowedFeatures(), extensions); |
99 | 100 |
100 EXPECT_TRUE(group_->Initialize(DisallowedFeatures(), NULL)); | 101 // We initialize the ContextGroup with a MockGLES2Decoder so that |
| 102 // we can use the ContextGroup to figure out how the real GLES2Decoder |
| 103 // will initialize itself. |
| 104 mock_decoder_.reset(new MockGLES2Decoder()); |
| 105 EXPECT_TRUE( |
| 106 group_->Initialize(mock_decoder_.get(), DisallowedFeatures(), NULL)); |
101 | 107 |
102 AddExpectationsForVertexAttribManager(); | 108 AddExpectationsForVertexAttribManager(); |
103 | 109 |
104 AddExpectationsForBindVertexArrayOES(); | 110 AddExpectationsForBindVertexArrayOES(); |
105 | 111 |
106 EXPECT_CALL(*gl_, EnableVertexAttribArray(0)) | 112 EXPECT_CALL(*gl_, EnableVertexAttribArray(0)) |
107 .Times(1) | 113 .Times(1) |
108 .RetiresOnSaturation(); | 114 .RetiresOnSaturation(); |
109 static GLuint attrib_0_id[] = { | 115 static GLuint attrib_0_id[] = { |
110 kServiceAttrib0BufferId, | 116 kServiceAttrib0BufferId, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 void GLES2DecoderTestBase::TearDown() { | 294 void GLES2DecoderTestBase::TearDown() { |
289 // All Tests should have read all their GLErrors before getting here. | 295 // All Tests should have read all their GLErrors before getting here. |
290 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 296 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
291 | 297 |
292 EXPECT_CALL(*gl_, DeleteBuffersARB(1, _)) | 298 EXPECT_CALL(*gl_, DeleteBuffersARB(1, _)) |
293 .Times(2) | 299 .Times(2) |
294 .RetiresOnSaturation(); | 300 .RetiresOnSaturation(); |
295 | 301 |
296 decoder_->Destroy(true); | 302 decoder_->Destroy(true); |
297 decoder_.reset(); | 303 decoder_.reset(); |
298 group_->Destroy(false); | 304 group_->Destroy(mock_decoder_.get(), false); |
299 engine_.reset(); | 305 engine_.reset(); |
300 ::gfx::GLInterface::SetGLInterface(NULL); | 306 ::gfx::GLInterface::SetGLInterface(NULL); |
301 gl_.reset(); | 307 gl_.reset(); |
302 } | 308 } |
303 | 309 |
304 void GLES2DecoderTestBase::ExpectEnableDisable(GLenum cap, bool enable) { | 310 void GLES2DecoderTestBase::ExpectEnableDisable(GLenum cap, bool enable) { |
305 if (enable) { | 311 if (enable) { |
306 EXPECT_CALL(*gl_, Enable(cap)) | 312 EXPECT_CALL(*gl_, Enable(cap)) |
307 .Times(1) | 313 .Times(1) |
308 .RetiresOnSaturation(); | 314 .RetiresOnSaturation(); |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 SetupDefaultProgram(); | 1380 SetupDefaultProgram(); |
1375 } | 1381 } |
1376 | 1382 |
1377 // Include the auto-generated part of this file. We split this because it means | 1383 // Include the auto-generated part of this file. We split this because it means |
1378 // we can easily edit the non-auto generated parts right here in this file | 1384 // we can easily edit the non-auto generated parts right here in this file |
1379 // instead of having to edit some template or the code generator. | 1385 // instead of having to edit some template or the code generator. |
1380 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" | 1386 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" |
1381 | 1387 |
1382 } // namespace gles2 | 1388 } // namespace gles2 |
1383 } // namespace gpu | 1389 } // namespace gpu |
OLD | NEW |