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_array_manager.h" | 5 #include "gpu/command_buffer/service/vertex_array_manager.h" |
6 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 6 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "gpu/command_buffer/service/feature_info.h" | 9 #include "gpu/command_buffer/service/feature_info.h" |
10 #include "gpu/command_buffer/service/gpu_service_test.h" | |
11 #include "gpu/command_buffer/service/test_helper.h" | 10 #include "gpu/command_buffer/service/test_helper.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/gl/gl_mock.h" | 12 #include "ui/gl/gl_mock.h" |
14 | 13 |
15 using ::testing::Pointee; | 14 using ::testing::Pointee; |
16 using ::testing::_; | 15 using ::testing::_; |
17 | 16 |
18 namespace gpu { | 17 namespace gpu { |
19 namespace gles2 { | 18 namespace gles2 { |
20 | 19 |
21 class VertexArrayManagerTest : public GpuServiceTest { | 20 class VertexArrayManagerTest : public testing::Test { |
22 public: | 21 public: |
23 static const uint32 kNumVertexAttribs = 8; | 22 static const uint32 kNumVertexAttribs = 8; |
24 | 23 |
25 VertexArrayManagerTest() { | 24 VertexArrayManagerTest() { |
26 } | 25 } |
27 | 26 |
28 virtual ~VertexArrayManagerTest() { | 27 virtual ~VertexArrayManagerTest() { |
29 } | 28 } |
30 | 29 |
31 protected: | 30 protected: |
32 virtual void SetUp() { | 31 virtual void SetUp() { |
33 GpuServiceTest::SetUp(); | 32 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); |
34 manager_.reset(new VertexArrayManager()); | 33 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); |
| 34 |
| 35 manager_ = new VertexArrayManager(); |
35 } | 36 } |
36 | 37 |
37 virtual void TearDown() { | 38 virtual void TearDown() { |
38 manager_.reset(); | 39 delete manager_; |
39 GpuServiceTest::TearDown(); | 40 ::gfx::MockGLInterface::SetGLInterface(NULL); |
| 41 gl_.reset(); |
40 } | 42 } |
41 | 43 |
42 scoped_ptr<VertexArrayManager> manager_; | 44 // Use StrictMock to make 100% sure we know how GL will be called. |
| 45 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; |
| 46 VertexArrayManager* manager_; |
43 }; | 47 }; |
44 | 48 |
45 // GCC requires these declarations, but MSVC requires they not be present | 49 // GCC requires these declarations, but MSVC requires they not be present |
46 #ifndef COMPILER_MSVC | 50 #ifndef COMPILER_MSVC |
47 const uint32 VertexArrayManagerTest::kNumVertexAttribs; | 51 const uint32 VertexArrayManagerTest::kNumVertexAttribs; |
48 #endif | 52 #endif |
49 | 53 |
50 TEST_F(VertexArrayManagerTest, Basic) { | 54 TEST_F(VertexArrayManagerTest, Basic) { |
51 const GLuint kClient1Id = 1; | 55 const GLuint kClient1Id = 1; |
52 const GLuint kService1Id = 11; | 56 const GLuint kService1Id = 11; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 manager.Destroy(true); | 95 manager.Destroy(true); |
92 // Check that resources got freed. | 96 // Check that resources got freed. |
93 info1 = manager.GetVertexAttribManager(kClient1Id); | 97 info1 = manager.GetVertexAttribManager(kClient1Id); |
94 ASSERT_TRUE(info1 == NULL); | 98 ASSERT_TRUE(info1 == NULL); |
95 } | 99 } |
96 | 100 |
97 } // namespace gles2 | 101 } // namespace gles2 |
98 } // namespace gpu | 102 } // namespace gpu |
99 | 103 |
100 | 104 |
OLD | NEW |