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/context_group.h" | 5 #include "gpu/command_buffer/service/context_group.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" | 8 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" |
| 9 #include "gpu/command_buffer/service/gpu_service_test.h" |
9 #include "gpu/command_buffer/service/test_helper.h" | 10 #include "gpu/command_buffer/service/test_helper.h" |
10 #include "gpu/command_buffer/service/texture_manager.h" | 11 #include "gpu/command_buffer/service/texture_manager.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/gl/gl_mock.h" | 13 #include "ui/gl/gl_mock.h" |
13 | 14 |
14 using ::gfx::MockGLInterface; | |
15 using ::testing::_; | 15 using ::testing::_; |
16 using ::testing::DoAll; | 16 using ::testing::DoAll; |
17 using ::testing::HasSubstr; | 17 using ::testing::HasSubstr; |
18 using ::testing::InSequence; | 18 using ::testing::InSequence; |
19 using ::testing::MatcherCast; | 19 using ::testing::MatcherCast; |
20 using ::testing::Not; | 20 using ::testing::Not; |
21 using ::testing::Pointee; | 21 using ::testing::Pointee; |
22 using ::testing::Return; | 22 using ::testing::Return; |
23 using ::testing::SetArrayArgument; | 23 using ::testing::SetArrayArgument; |
24 using ::testing::SetArgumentPointee; | 24 using ::testing::SetArgumentPointee; |
25 using ::testing::StrEq; | 25 using ::testing::StrEq; |
26 using ::testing::StrictMock; | |
27 | 26 |
28 namespace gpu { | 27 namespace gpu { |
29 namespace gles2 { | 28 namespace gles2 { |
30 | 29 |
31 class ContextGroupTest : public testing::Test { | 30 class ContextGroupTest : public GpuServiceTest { |
32 public: | 31 public: |
33 static const bool kBindGeneratesResource = false; | 32 static const bool kBindGeneratesResource = false; |
34 | 33 |
35 ContextGroupTest() {} | 34 ContextGroupTest() {} |
36 | 35 |
37 protected: | 36 protected: |
38 virtual void SetUp() { | 37 virtual void SetUp() { |
39 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); | 38 GpuServiceTest::SetUp(); |
40 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); | |
41 decoder_.reset(new MockGLES2Decoder()); | 39 decoder_.reset(new MockGLES2Decoder()); |
42 group_ = scoped_refptr<ContextGroup>( | 40 group_ = scoped_refptr<ContextGroup>( |
43 new ContextGroup(NULL, NULL, NULL, NULL, NULL, kBindGeneratesResource)); | 41 new ContextGroup(NULL, NULL, NULL, NULL, NULL, kBindGeneratesResource)); |
44 } | 42 } |
45 | 43 |
46 virtual void TearDown() { | |
47 ::gfx::MockGLInterface::SetGLInterface(NULL); | |
48 gl_.reset(); | |
49 } | |
50 | |
51 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; | |
52 scoped_ptr<MockGLES2Decoder> decoder_; | 44 scoped_ptr<MockGLES2Decoder> decoder_; |
53 scoped_refptr<ContextGroup> group_; | 45 scoped_refptr<ContextGroup> group_; |
54 }; | 46 }; |
55 | 47 |
56 TEST_F(ContextGroupTest, Basic) { | 48 TEST_F(ContextGroupTest, Basic) { |
57 // Test it starts off uninitialized. | 49 // Test it starts off uninitialized. |
58 EXPECT_EQ(0u, group_->max_vertex_attribs()); | 50 EXPECT_EQ(0u, group_->max_vertex_attribs()); |
59 EXPECT_EQ(0u, group_->max_texture_units()); | 51 EXPECT_EQ(0u, group_->max_texture_units()); |
60 EXPECT_EQ(0u, group_->max_texture_image_units()); | 52 EXPECT_EQ(0u, group_->max_texture_image_units()); |
61 EXPECT_EQ(0u, group_->max_vertex_texture_image_units()); | 53 EXPECT_EQ(0u, group_->max_vertex_texture_image_units()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 EXPECT_TRUE(group_->renderbuffer_manager() == NULL); | 126 EXPECT_TRUE(group_->renderbuffer_manager() == NULL); |
135 EXPECT_TRUE(group_->texture_manager() == NULL); | 127 EXPECT_TRUE(group_->texture_manager() == NULL); |
136 EXPECT_TRUE(group_->program_manager() == NULL); | 128 EXPECT_TRUE(group_->program_manager() == NULL); |
137 EXPECT_TRUE(group_->shader_manager() == NULL); | 129 EXPECT_TRUE(group_->shader_manager() == NULL); |
138 } | 130 } |
139 | 131 |
140 } // namespace gles2 | 132 } // namespace gles2 |
141 } // namespace gpu | 133 } // namespace gpu |
142 | 134 |
143 | 135 |
OLD | NEW |