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

Unified Diff: gpu/command_buffer/service/texture_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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/texture_manager_unittest.cc
===================================================================
--- gpu/command_buffer/service/texture_manager_unittest.cc (revision 51426)
+++ gpu/command_buffer/service/texture_manager_unittest.cc (working copy)
@@ -3,8 +3,12 @@
// found in the LICENSE file.
#include "gpu/command_buffer/service/texture_manager.h"
+#include "base/scoped_ptr.h"
+#include "app/gfx/gl/gl_mock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using ::testing::Pointee;
+
namespace gpu {
namespace gles2 {
@@ -19,13 +23,23 @@
: manager_(kMaxTextureSize, kMaxCubeMapTextureSize) {
}
+ ~TextureManagerTest() {
+ manager_.Destroy(false);
+ }
+
protected:
virtual void SetUp() {
+ gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>());
+ ::gfx::GLInterface::SetGLInterface(gl_.get());
}
virtual void TearDown() {
+ ::gfx::GLInterface::SetGLInterface(NULL);
+ gl_.reset();
}
+ // Use StrictMock to make 100% sure we know how GL will be called.
+ scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
TextureManager manager_;
};
@@ -60,6 +74,24 @@
EXPECT_TRUE(manager_.GetTextureInfo(kClient1Id) == NULL);
}
+TEST_F(TextureManagerTest, Destroy) {
+ const GLuint kClient1Id = 1;
+ const GLuint kService1Id = 11;
+ EXPECT_FALSE(manager_.HaveUnrenderableTextures());
+ // Check we can create texture.
+ manager_.CreateTextureInfo(kClient1Id, kService1Id);
+ // Check texture got created.
+ TextureManager::TextureInfo* info1 = manager_.GetTextureInfo(kClient1Id);
+ ASSERT_TRUE(info1 != NULL);
+ EXPECT_CALL(*gl_, DeleteTextures(1, ::testing::Pointee(kService1Id)))
+ .Times(1)
+ .RetiresOnSaturation();
+ manager_.Destroy(true);
+ // Check that resources got freed.
+ info1 = manager_.GetTextureInfo(kClient1Id);
+ ASSERT_TRUE(info1 == NULL);
+}
+
TEST_F(TextureManagerTest, MaxValues) {
// Check we get the right values for the max sizes.
EXPECT_EQ(kMax2dLevels, manager_.MaxLevelsForTarget(GL_TEXTURE_2D));
@@ -126,17 +158,26 @@
TextureInfoTest()
: manager_(kMaxTextureSize, kMaxCubeMapTextureSize) {
}
+ ~TextureInfoTest() {
+ manager_.Destroy(false);
+ }
protected:
virtual void SetUp() {
+ gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>());
+ ::gfx::GLInterface::SetGLInterface(gl_.get());
manager_.CreateTextureInfo(kClient1Id, kService1Id);
info_ = manager_.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info_ != NULL);
}
virtual void TearDown() {
+ ::gfx::GLInterface::SetGLInterface(NULL);
+ gl_.reset();
}
+ // Use StrictMock to make 100% sure we know how GL will be called.
+ scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
TextureManager manager_;
TextureManager::TextureInfo* info_;
};
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698