Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: gpu/command_buffer/service/context_group_unittest.cc

Issue 11568029: Add a command to lose the context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add docs, lose parent and children, fix typo Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/context_group.cc ('k') | gpu/command_buffer/service/feature_info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test_helper.h" 9 #include "gpu/command_buffer/service/test_helper.h"
9 #include "gpu/command_buffer/service/texture_manager.h" 10 #include "gpu/command_buffer/service/texture_manager.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/gl/gl_mock.h" 12 #include "ui/gl/gl_mock.h"
12 13
13 using ::gfx::MockGLInterface; 14 using ::gfx::MockGLInterface;
14 using ::testing::_; 15 using ::testing::_;
15 using ::testing::DoAll; 16 using ::testing::DoAll;
16 using ::testing::HasSubstr; 17 using ::testing::HasSubstr;
17 using ::testing::InSequence; 18 using ::testing::InSequence;
(...skipping 11 matching lines...) Expand all
29 30
30 class ContextGroupTest : public testing::Test { 31 class ContextGroupTest : public testing::Test {
31 public: 32 public:
32 ContextGroupTest() { 33 ContextGroupTest() {
33 } 34 }
34 35
35 protected: 36 protected:
36 virtual void SetUp() { 37 virtual void SetUp() {
37 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); 38 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>());
38 ::gfx::GLInterface::SetGLInterface(gl_.get()); 39 ::gfx::GLInterface::SetGLInterface(gl_.get());
40 decoder_.reset(new MockGLES2Decoder());
39 group_ = ContextGroup::Ref(new ContextGroup(NULL, NULL, NULL, true)); 41 group_ = ContextGroup::Ref(new ContextGroup(NULL, NULL, NULL, true));
40 } 42 }
41 43
42 virtual void TearDown() { 44 virtual void TearDown() {
43 ::gfx::GLInterface::SetGLInterface(NULL); 45 ::gfx::GLInterface::SetGLInterface(NULL);
44 gl_.reset(); 46 gl_.reset();
45 } 47 }
46 48
47 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; 49 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
50 scoped_ptr<MockGLES2Decoder> decoder_;
48 ContextGroup::Ref group_; 51 ContextGroup::Ref group_;
49 }; 52 };
50 53
51 TEST_F(ContextGroupTest, Basic) { 54 TEST_F(ContextGroupTest, Basic) {
52 // Test it starts off uninitialized. 55 // Test it starts off uninitialized.
53 EXPECT_EQ(0u, group_->max_vertex_attribs()); 56 EXPECT_EQ(0u, group_->max_vertex_attribs());
54 EXPECT_EQ(0u, group_->max_texture_units()); 57 EXPECT_EQ(0u, group_->max_texture_units());
55 EXPECT_EQ(0u, group_->max_texture_image_units()); 58 EXPECT_EQ(0u, group_->max_texture_image_units());
56 EXPECT_EQ(0u, group_->max_vertex_texture_image_units()); 59 EXPECT_EQ(0u, group_->max_vertex_texture_image_units());
57 EXPECT_EQ(0u, group_->max_fragment_uniform_vectors()); 60 EXPECT_EQ(0u, group_->max_fragment_uniform_vectors());
58 EXPECT_EQ(0u, group_->max_varying_vectors()); 61 EXPECT_EQ(0u, group_->max_varying_vectors());
59 EXPECT_EQ(0u, group_->max_vertex_uniform_vectors()); 62 EXPECT_EQ(0u, group_->max_vertex_uniform_vectors());
60 EXPECT_TRUE(group_->buffer_manager() == NULL); 63 EXPECT_TRUE(group_->buffer_manager() == NULL);
61 EXPECT_TRUE(group_->framebuffer_manager() == NULL); 64 EXPECT_TRUE(group_->framebuffer_manager() == NULL);
62 EXPECT_TRUE(group_->renderbuffer_manager() == NULL); 65 EXPECT_TRUE(group_->renderbuffer_manager() == NULL);
63 EXPECT_TRUE(group_->texture_manager() == NULL); 66 EXPECT_TRUE(group_->texture_manager() == NULL);
64 EXPECT_TRUE(group_->program_manager() == NULL); 67 EXPECT_TRUE(group_->program_manager() == NULL);
65 EXPECT_TRUE(group_->shader_manager() == NULL); 68 EXPECT_TRUE(group_->shader_manager() == NULL);
66 } 69 }
67 70
68 TEST_F(ContextGroupTest, InitializeNoExtensions) { 71 TEST_F(ContextGroupTest, InitializeNoExtensions) {
69 TestHelper::SetupContextGroupInitExpectations(gl_.get(), 72 TestHelper::SetupContextGroupInitExpectations(gl_.get(),
70 DisallowedFeatures(), ""); 73 DisallowedFeatures(), "");
71 group_->Initialize(DisallowedFeatures(), ""); 74 group_->Initialize(decoder_.get(), DisallowedFeatures(), "");
72 EXPECT_EQ(static_cast<uint32>(TestHelper::kNumVertexAttribs), 75 EXPECT_EQ(static_cast<uint32>(TestHelper::kNumVertexAttribs),
73 group_->max_vertex_attribs()); 76 group_->max_vertex_attribs());
74 EXPECT_EQ(static_cast<uint32>(TestHelper::kNumTextureUnits), 77 EXPECT_EQ(static_cast<uint32>(TestHelper::kNumTextureUnits),
75 group_->max_texture_units()); 78 group_->max_texture_units());
76 EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxTextureImageUnits), 79 EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxTextureImageUnits),
77 group_->max_texture_image_units()); 80 group_->max_texture_image_units());
78 EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxVertexTextureImageUnits), 81 EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxVertexTextureImageUnits),
79 group_->max_vertex_texture_image_units()); 82 group_->max_vertex_texture_image_units());
80 EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxFragmentUniformVectors), 83 EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxFragmentUniformVectors),
81 group_->max_fragment_uniform_vectors()); 84 group_->max_fragment_uniform_vectors());
82 EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxVaryingVectors), 85 EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxVaryingVectors),
83 group_->max_varying_vectors()); 86 group_->max_varying_vectors());
84 EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxVertexUniformVectors), 87 EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxVertexUniformVectors),
85 group_->max_vertex_uniform_vectors()); 88 group_->max_vertex_uniform_vectors());
86 EXPECT_TRUE(group_->buffer_manager() != NULL); 89 EXPECT_TRUE(group_->buffer_manager() != NULL);
87 EXPECT_TRUE(group_->framebuffer_manager() != NULL); 90 EXPECT_TRUE(group_->framebuffer_manager() != NULL);
88 EXPECT_TRUE(group_->renderbuffer_manager() != NULL); 91 EXPECT_TRUE(group_->renderbuffer_manager() != NULL);
89 EXPECT_TRUE(group_->texture_manager() != NULL); 92 EXPECT_TRUE(group_->texture_manager() != NULL);
90 EXPECT_TRUE(group_->program_manager() != NULL); 93 EXPECT_TRUE(group_->program_manager() != NULL);
91 EXPECT_TRUE(group_->shader_manager() != NULL); 94 EXPECT_TRUE(group_->shader_manager() != NULL);
92 95
93 group_->Destroy(false); 96 group_->Destroy(decoder_.get(), false);
94 EXPECT_TRUE(group_->buffer_manager() == NULL); 97 EXPECT_TRUE(group_->buffer_manager() == NULL);
95 EXPECT_TRUE(group_->framebuffer_manager() == NULL); 98 EXPECT_TRUE(group_->framebuffer_manager() == NULL);
96 EXPECT_TRUE(group_->renderbuffer_manager() == NULL); 99 EXPECT_TRUE(group_->renderbuffer_manager() == NULL);
97 EXPECT_TRUE(group_->texture_manager() == NULL); 100 EXPECT_TRUE(group_->texture_manager() == NULL);
98 EXPECT_TRUE(group_->program_manager() == NULL); 101 EXPECT_TRUE(group_->program_manager() == NULL);
99 EXPECT_TRUE(group_->shader_manager() == NULL); 102 EXPECT_TRUE(group_->shader_manager() == NULL);
100 } 103 }
101 104
102 TEST_F(ContextGroupTest, MultipleContexts) { 105 TEST_F(ContextGroupTest, MultipleContexts) {
106 scoped_ptr<MockGLES2Decoder> decoder2_(new MockGLES2Decoder());
103 TestHelper::SetupContextGroupInitExpectations(gl_.get(), 107 TestHelper::SetupContextGroupInitExpectations(gl_.get(),
104 DisallowedFeatures(), ""); 108 DisallowedFeatures(), "");
105 group_->Initialize(DisallowedFeatures(), ""); 109 group_->Initialize(decoder_.get(), DisallowedFeatures(), "");
106 group_->Initialize(DisallowedFeatures(), ""); 110 group_->Initialize(decoder2_.get(), DisallowedFeatures(), "");
107 111
108 EXPECT_TRUE(group_->buffer_manager() != NULL); 112 EXPECT_TRUE(group_->buffer_manager() != NULL);
109 EXPECT_TRUE(group_->framebuffer_manager() != NULL); 113 EXPECT_TRUE(group_->framebuffer_manager() != NULL);
110 EXPECT_TRUE(group_->renderbuffer_manager() != NULL); 114 EXPECT_TRUE(group_->renderbuffer_manager() != NULL);
111 EXPECT_TRUE(group_->texture_manager() != NULL); 115 EXPECT_TRUE(group_->texture_manager() != NULL);
112 EXPECT_TRUE(group_->program_manager() != NULL); 116 EXPECT_TRUE(group_->program_manager() != NULL);
113 EXPECT_TRUE(group_->shader_manager() != NULL); 117 EXPECT_TRUE(group_->shader_manager() != NULL);
114 118
115 group_->Destroy(false); 119 group_->Destroy(decoder_.get(), false);
116 120
117 EXPECT_TRUE(group_->buffer_manager() != NULL); 121 EXPECT_TRUE(group_->buffer_manager() != NULL);
118 EXPECT_TRUE(group_->framebuffer_manager() != NULL); 122 EXPECT_TRUE(group_->framebuffer_manager() != NULL);
119 EXPECT_TRUE(group_->renderbuffer_manager() != NULL); 123 EXPECT_TRUE(group_->renderbuffer_manager() != NULL);
120 EXPECT_TRUE(group_->texture_manager() != NULL); 124 EXPECT_TRUE(group_->texture_manager() != NULL);
121 EXPECT_TRUE(group_->program_manager() != NULL); 125 EXPECT_TRUE(group_->program_manager() != NULL);
122 EXPECT_TRUE(group_->shader_manager() != NULL); 126 EXPECT_TRUE(group_->shader_manager() != NULL);
123 127
124 group_->Destroy(false); 128 group_->Destroy(decoder2_.get(), false);
125 129
126 EXPECT_TRUE(group_->buffer_manager() == NULL); 130 EXPECT_TRUE(group_->buffer_manager() == NULL);
127 EXPECT_TRUE(group_->framebuffer_manager() == NULL); 131 EXPECT_TRUE(group_->framebuffer_manager() == NULL);
128 EXPECT_TRUE(group_->renderbuffer_manager() == NULL); 132 EXPECT_TRUE(group_->renderbuffer_manager() == NULL);
129 EXPECT_TRUE(group_->texture_manager() == NULL); 133 EXPECT_TRUE(group_->texture_manager() == NULL);
130 EXPECT_TRUE(group_->program_manager() == NULL); 134 EXPECT_TRUE(group_->program_manager() == NULL);
131 EXPECT_TRUE(group_->shader_manager() == NULL); 135 EXPECT_TRUE(group_->shader_manager() == NULL);
132 } 136 }
133 137
134 } // namespace gles2 138 } // namespace gles2
135 } // namespace gpu 139 } // namespace gpu
136 140
137 141
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/context_group.cc ('k') | gpu/command_buffer/service/feature_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698