OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/context_group.h" | 5 #include "gpu/command_buffer/service/context_group.h" |
6 #include "app/gfx/gl/gl_mock.h" | 6 #include "app/gfx/gl/gl_mock.h" |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "gpu/command_buffer/service/test_helper.h" |
8 #include "gpu/command_buffer/service/texture_manager.h" | 9 #include "gpu/command_buffer/service/texture_manager.h" |
9 #include "gpu/GLES2/gles2_command_buffer.h" | 10 #include "gpu/GLES2/gles2_command_buffer.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 using ::gfx::MockGLInterface; | 13 using ::gfx::MockGLInterface; |
13 using ::testing::_; | 14 using ::testing::_; |
14 using ::testing::DoAll; | 15 using ::testing::DoAll; |
15 using ::testing::HasSubstr; | 16 using ::testing::HasSubstr; |
16 using ::testing::InSequence; | 17 using ::testing::InSequence; |
17 using ::testing::MatcherCast; | 18 using ::testing::MatcherCast; |
18 using ::testing::Not; | 19 using ::testing::Not; |
19 using ::testing::Pointee; | 20 using ::testing::Pointee; |
20 using ::testing::Return; | 21 using ::testing::Return; |
21 using ::testing::SetArrayArgument; | 22 using ::testing::SetArrayArgument; |
22 using ::testing::SetArgumentPointee; | 23 using ::testing::SetArgumentPointee; |
23 using ::testing::StrEq; | 24 using ::testing::StrEq; |
24 using ::testing::StrictMock; | 25 using ::testing::StrictMock; |
25 | 26 |
26 namespace gpu { | 27 namespace gpu { |
27 namespace gles2 { | 28 namespace gles2 { |
28 | 29 |
29 class ContextGroupTest : public testing::Test { | 30 class ContextGroupTest : public testing::Test { |
30 public: | 31 public: |
31 ContextGroupTest() { | 32 ContextGroupTest() { |
32 } | 33 } |
33 | 34 |
34 void SetupInitExpectations(const char* extensions); | 35 void SetupInitExpectations(const char* extensions) { |
| 36 TestHelper::SetupContextGroupInitExpectations(gl_.get(), extensions); |
| 37 } |
35 | 38 |
36 protected: | 39 protected: |
37 static const GLint kMaxTextureSize = 2048; | |
38 static const GLint kMaxCubeMapTextureSize = 256; | |
39 static const GLint kNumVertexAttribs = 16; | |
40 static const GLint kNumTextureUnits = 8; | |
41 static const GLint kMaxTextureImageUnits = 8; | |
42 static const GLint kMaxVertexTextureImageUnits = 2; | |
43 static const GLint kMaxFragmentUniformVectors = 16; | |
44 static const GLint kMaxVaryingVectors = 8; | |
45 static const GLint kMaxVertexUniformVectors = 128; | |
46 | |
47 virtual void SetUp() { | 40 virtual void SetUp() { |
48 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); | 41 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); |
49 ::gfx::GLInterface::SetGLInterface(gl_.get()); | 42 ::gfx::GLInterface::SetGLInterface(gl_.get()); |
50 } | 43 } |
51 | 44 |
52 virtual void TearDown() { | 45 virtual void TearDown() { |
53 group_.Destroy(false); | 46 group_.Destroy(false); |
54 ::gfx::GLInterface::SetGLInterface(NULL); | 47 ::gfx::GLInterface::SetGLInterface(NULL); |
55 gl_.reset(); | 48 gl_.reset(); |
56 } | 49 } |
57 | 50 |
58 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; | 51 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; |
59 ContextGroup group_; | 52 ContextGroup group_; |
60 }; | 53 }; |
61 | 54 |
62 // GCC requires these declarations, but MSVC requires they not be present | |
63 #ifndef COMPILER_MSVC | |
64 const GLint ContextGroupTest::kMaxTextureSize; | |
65 const GLint ContextGroupTest::kMaxCubeMapTextureSize; | |
66 const GLint ContextGroupTest::kNumVertexAttribs; | |
67 const GLint ContextGroupTest::kNumTextureUnits; | |
68 const GLint ContextGroupTest::kMaxTextureImageUnits; | |
69 const GLint ContextGroupTest::kMaxVertexTextureImageUnits; | |
70 const GLint ContextGroupTest::kMaxFragmentUniformVectors; | |
71 const GLint ContextGroupTest::kMaxVaryingVectors; | |
72 const GLint ContextGroupTest::kMaxVertexUniformVectors; | |
73 #endif | |
74 | |
75 void ContextGroupTest::SetupInitExpectations(const char* extensions) { | |
76 InSequence sequence; | |
77 | |
78 EXPECT_CALL(*gl_, GetString(GL_EXTENSIONS)) | |
79 .WillOnce(Return(reinterpret_cast<const uint8*>(extensions))) | |
80 .RetiresOnSaturation(); | |
81 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _)) | |
82 .WillOnce(SetArgumentPointee<1>(kNumVertexAttribs)) | |
83 .RetiresOnSaturation(); | |
84 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, _)) | |
85 .WillOnce(SetArgumentPointee<1>(kNumTextureUnits)) | |
86 .RetiresOnSaturation(); | |
87 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_TEXTURE_SIZE, _)) | |
88 .WillOnce(SetArgumentPointee<1>(kMaxTextureSize)) | |
89 .RetiresOnSaturation(); | |
90 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, _)) | |
91 .WillOnce(SetArgumentPointee<1>(kMaxCubeMapTextureSize)) | |
92 .RetiresOnSaturation(); | |
93 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, _)) | |
94 .WillOnce(SetArgumentPointee<1>(kMaxTextureImageUnits)) | |
95 .RetiresOnSaturation(); | |
96 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, _)) | |
97 .WillOnce(SetArgumentPointee<1>(kMaxVertexTextureImageUnits)) | |
98 .RetiresOnSaturation(); | |
99 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, _)) | |
100 .WillOnce(SetArgumentPointee<1>(kMaxFragmentUniformVectors)) | |
101 .RetiresOnSaturation(); | |
102 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VARYING_FLOATS, _)) | |
103 .WillOnce(SetArgumentPointee<1>(kMaxVaryingVectors)) | |
104 .RetiresOnSaturation(); | |
105 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, _)) | |
106 .WillOnce(SetArgumentPointee<1>(kMaxVertexUniformVectors)) | |
107 .RetiresOnSaturation(); | |
108 } | |
109 | |
110 TEST_F(ContextGroupTest, Basic) { | 55 TEST_F(ContextGroupTest, Basic) { |
111 // Test it starts off uninitialized. | 56 // Test it starts off uninitialized. |
112 EXPECT_EQ(0u, group_.max_vertex_attribs()); | 57 EXPECT_EQ(0u, group_.max_vertex_attribs()); |
113 EXPECT_EQ(0u, group_.max_texture_units()); | 58 EXPECT_EQ(0u, group_.max_texture_units()); |
114 EXPECT_EQ(0u, group_.max_texture_image_units()); | 59 EXPECT_EQ(0u, group_.max_texture_image_units()); |
115 EXPECT_EQ(0u, group_.max_vertex_texture_image_units()); | 60 EXPECT_EQ(0u, group_.max_vertex_texture_image_units()); |
116 EXPECT_EQ(0u, group_.max_fragment_uniform_vectors()); | 61 EXPECT_EQ(0u, group_.max_fragment_uniform_vectors()); |
117 EXPECT_EQ(0u, group_.max_varying_vectors()); | 62 EXPECT_EQ(0u, group_.max_varying_vectors()); |
118 EXPECT_EQ(0u, group_.max_vertex_uniform_vectors()); | 63 EXPECT_EQ(0u, group_.max_vertex_uniform_vectors()); |
119 EXPECT_TRUE(group_.buffer_manager() == NULL); | 64 EXPECT_TRUE(group_.buffer_manager() == NULL); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 EXPECT_TRUE(group_.validators()->g_l_state.IsValid( | 247 EXPECT_TRUE(group_.validators()->g_l_state.IsValid( |
303 GL_DRAW_FRAMEBUFFER_BINDING_EXT)); | 248 GL_DRAW_FRAMEBUFFER_BINDING_EXT)); |
304 EXPECT_TRUE(group_.validators()->render_buffer_parameter.IsValid( | 249 EXPECT_TRUE(group_.validators()->render_buffer_parameter.IsValid( |
305 GL_MAX_SAMPLES_EXT)); | 250 GL_MAX_SAMPLES_EXT)); |
306 } | 251 } |
307 | 252 |
308 } // namespace gles2 | 253 } // namespace gles2 |
309 } // namespace gpu | 254 } // namespace gpu |
310 | 255 |
311 | 256 |
OLD | NEW |