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/vertex_attrib_manager.h" | 5 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "gpu/command_buffer/service/buffer_manager.h" | 8 #include "gpu/command_buffer/service/buffer_manager.h" |
9 #include "gpu/command_buffer/service/error_state_mock.h" | 9 #include "gpu/command_buffer/service/error_state_mock.h" |
10 #include "gpu/command_buffer/service/feature_info.h" | 10 #include "gpu/command_buffer/service/feature_info.h" |
11 #include "gpu/command_buffer/service/gpu_service_test.h" | |
12 #include "gpu/command_buffer/service/test_helper.h" | 11 #include "gpu/command_buffer/service/test_helper.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/gl/gl_mock.h" | 13 #include "ui/gl/gl_mock.h" |
15 | 14 |
16 using ::testing::Pointee; | 15 using ::testing::Pointee; |
17 using ::testing::_; | 16 using ::testing::_; |
18 | 17 |
19 namespace gpu { | 18 namespace gpu { |
20 namespace gles2 { | 19 namespace gles2 { |
21 | 20 |
22 class VertexAttribManagerTest : public GpuServiceTest { | 21 class VertexAttribManagerTest : public testing::Test { |
23 public: | 22 public: |
24 static const uint32 kNumVertexAttribs = 8; | 23 static const uint32 kNumVertexAttribs = 8; |
25 | 24 |
26 VertexAttribManagerTest() { | 25 VertexAttribManagerTest() { |
27 } | 26 } |
28 | 27 |
29 virtual ~VertexAttribManagerTest() { | 28 virtual ~VertexAttribManagerTest() { |
30 } | 29 } |
31 | 30 |
32 protected: | 31 protected: |
33 virtual void SetUp() { | 32 virtual void SetUp() { |
34 GpuServiceTest::SetUp(); | 33 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); |
| 34 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); |
35 | 35 |
36 for (uint32 ii = 0; ii < kNumVertexAttribs; ++ii) { | 36 for (uint32 ii = 0; ii < kNumVertexAttribs; ++ii) { |
37 EXPECT_CALL(*gl_, VertexAttrib4f(ii, 0.0f, 0.0f, 0.0f, 1.0f)) | 37 EXPECT_CALL(*gl_, VertexAttrib4f(ii, 0.0f, 0.0f, 0.0f, 1.0f)) |
38 .Times(1) | 38 .Times(1) |
39 .RetiresOnSaturation(); | 39 .RetiresOnSaturation(); |
40 } | 40 } |
41 | 41 |
42 manager_ = new VertexAttribManager(); | 42 manager_ = new VertexAttribManager(); |
43 manager_->Initialize(kNumVertexAttribs, true); | 43 manager_->Initialize(kNumVertexAttribs, true); |
44 } | 44 } |
45 | 45 |
| 46 virtual void TearDown() { |
| 47 manager_ = NULL; |
| 48 ::gfx::MockGLInterface::SetGLInterface(NULL); |
| 49 gl_.reset(); |
| 50 } |
| 51 |
| 52 // Use StrictMock to make 100% sure we know how GL will be called. |
| 53 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; |
46 scoped_refptr<VertexAttribManager> manager_; | 54 scoped_refptr<VertexAttribManager> manager_; |
47 }; | 55 }; |
48 | 56 |
49 // GCC requires these declarations, but MSVC requires they not be present | 57 // GCC requires these declarations, but MSVC requires they not be present |
50 #ifndef COMPILER_MSVC | 58 #ifndef COMPILER_MSVC |
51 const uint32 VertexAttribManagerTest::kNumVertexAttribs; | 59 const uint32 VertexAttribManagerTest::kNumVertexAttribs; |
52 #endif | 60 #endif |
53 | 61 |
54 TEST_F(VertexAttribManagerTest, Basic) { | 62 TEST_F(VertexAttribManagerTest, Basic) { |
55 EXPECT_TRUE(manager_->GetVertexAttrib(kNumVertexAttribs) == NULL); | 63 EXPECT_TRUE(manager_->GetVertexAttrib(kNumVertexAttribs) == NULL); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 buffer_manager.Destroy(false); | 224 buffer_manager.Destroy(false); |
217 } | 225 } |
218 | 226 |
219 // TODO(gman): Test ValidateBindings | 227 // TODO(gman): Test ValidateBindings |
220 // TODO(gman): Test ValidateBindings with client side arrays. | 228 // TODO(gman): Test ValidateBindings with client side arrays. |
221 | 229 |
222 } // namespace gles2 | 230 } // namespace gles2 |
223 } // namespace gpu | 231 } // namespace gpu |
224 | 232 |
225 | 233 |
OLD | NEW |