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

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

Issue 2880013: Free the resources used by a context group. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months 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
OLDNEW
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/framebuffer_manager.h" 5 #include "gpu/command_buffer/service/framebuffer_manager.h"
6 #include "app/gfx/gl/gl_mock.h"
6 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
7 8
8 namespace gpu { 9 namespace gpu {
9 namespace gles2 { 10 namespace gles2 {
10 11
11 class FramebufferManagerTest : public testing::Test { 12 class FramebufferManagerTest : public testing::Test {
12 public: 13 public:
13 FramebufferManagerTest() { 14 FramebufferManagerTest() {
14 } 15 }
16 ~FramebufferManagerTest() {
17 manager_.Destroy(false);
18 }
15 19
16 protected: 20 protected:
17 virtual void SetUp() { 21 virtual void SetUp() {
22 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>());
23 ::gfx::GLInterface::SetGLInterface(gl_.get());
18 } 24 }
19 25
20 virtual void TearDown() { 26 virtual void TearDown() {
27 ::gfx::GLInterface::SetGLInterface(NULL);
28 gl_.reset();
21 } 29 }
22 30
31 // Use StrictMock to make 100% sure we know how GL will be called.
32 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
23 FramebufferManager manager_; 33 FramebufferManager manager_;
24 }; 34 };
25 35
26 TEST_F(FramebufferManagerTest, Basic) { 36 TEST_F(FramebufferManagerTest, Basic) {
27 const GLuint kClient1Id = 1; 37 const GLuint kClient1Id = 1;
28 const GLuint kService1Id = 11; 38 const GLuint kService1Id = 11;
29 const GLuint kClient2Id = 2; 39 const GLuint kClient2Id = 2;
30 // Check we can create framebuffer. 40 // Check we can create framebuffer.
31 manager_.CreateFramebufferInfo(kClient1Id, kService1Id); 41 manager_.CreateFramebufferInfo(kClient1Id, kService1Id);
32 // Check framebuffer got created. 42 // Check framebuffer got created.
33 FramebufferManager::FramebufferInfo* info1 = 43 FramebufferManager::FramebufferInfo* info1 =
34 manager_.GetFramebufferInfo(kClient1Id); 44 manager_.GetFramebufferInfo(kClient1Id);
35 ASSERT_TRUE(info1 != NULL); 45 ASSERT_TRUE(info1 != NULL);
36 EXPECT_FALSE(info1->IsDeleted()); 46 EXPECT_FALSE(info1->IsDeleted());
37 EXPECT_EQ(kService1Id, info1->service_id()); 47 EXPECT_EQ(kService1Id, info1->service_id());
38 GLuint client_id = 0; 48 GLuint client_id = 0;
39 EXPECT_TRUE(manager_.GetClientId(info1->service_id(), &client_id)); 49 EXPECT_TRUE(manager_.GetClientId(info1->service_id(), &client_id));
40 EXPECT_EQ(kClient1Id, client_id); 50 EXPECT_EQ(kClient1Id, client_id);
41 // Check we get nothing for a non-existent framebuffer. 51 // Check we get nothing for a non-existent framebuffer.
42 EXPECT_TRUE(manager_.GetFramebufferInfo(kClient2Id) == NULL); 52 EXPECT_TRUE(manager_.GetFramebufferInfo(kClient2Id) == NULL);
43 // Check trying to a remove non-existent framebuffers does not crash. 53 // Check trying to a remove non-existent framebuffers does not crash.
44 manager_.RemoveFramebufferInfo(kClient2Id); 54 manager_.RemoveFramebufferInfo(kClient2Id);
45 // Check we can't get the framebuffer after we remove it. 55 // Check we can't get the framebuffer after we remove it.
46 manager_.RemoveFramebufferInfo(kClient1Id); 56 manager_.RemoveFramebufferInfo(kClient1Id);
47 EXPECT_TRUE(manager_.GetFramebufferInfo(kClient1Id) == NULL); 57 EXPECT_TRUE(manager_.GetFramebufferInfo(kClient1Id) == NULL);
48 } 58 }
49 59
60 TEST_F(FramebufferManagerTest, Destroy) {
61 const GLuint kClient1Id = 1;
62 const GLuint kService1Id = 11;
63 // Check we can create framebuffer.
64 manager_.CreateFramebufferInfo(kClient1Id, kService1Id);
65 // Check framebuffer got created.
66 FramebufferManager::FramebufferInfo* info1 =
67 manager_.GetFramebufferInfo(kClient1Id);
68 ASSERT_TRUE(info1 != NULL);
69 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, ::testing::Pointee(kService1Id)))
70 .Times(1)
71 .RetiresOnSaturation();
72 manager_.Destroy(true);
73 // Check the resources were released.
74 info1 = manager_.GetFramebufferInfo(kClient1Id);
75 ASSERT_TRUE(info1 == NULL);
76 }
77
50 // TODO(gman): Write test for AttachRenderbuffer 78 // TODO(gman): Write test for AttachRenderbuffer
51 79
52 } // namespace gles2 80 } // namespace gles2
53 } // namespace gpu 81 } // namespace gpu
54 82
55 83
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698