diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-09 14:16:12 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-09 14:16:12 +0100 |
commit | 03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (patch) | |
tree | 52599cd0ab782b1768e23ad176f7618f98333cb6 /Source/WebKit/chromium/tests/TextureManagerTest.cpp | |
parent | cd44dc59cdfc39534aef4d417e9f3c412e3be139 (diff) | |
download | qtwebkit-03e12282df9aa1e1fb05a8b90f1cfc2e08764cec.tar.gz |
Imported WebKit commit e09a82039aa4273ab318b71122e92d8e5f233525 (http://svn.webkit.org/repository/webkit/trunk@107223)
Diffstat (limited to 'Source/WebKit/chromium/tests/TextureManagerTest.cpp')
-rw-r--r-- | Source/WebKit/chromium/tests/TextureManagerTest.cpp | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/Source/WebKit/chromium/tests/TextureManagerTest.cpp b/Source/WebKit/chromium/tests/TextureManagerTest.cpp index 6fe616c24..3b576af99 100644 --- a/Source/WebKit/chromium/tests/TextureManagerTest.cpp +++ b/Source/WebKit/chromium/tests/TextureManagerTest.cpp @@ -24,6 +24,7 @@ #include "config.h" +#include "ManagedTexture.h" #include "TextureManager.h" #include <gtest/gtest.h> @@ -64,8 +65,7 @@ public: bool requestTexture(TextureManager* manager, TextureToken token) { - unsigned textureId; - bool result = manager->requestTexture(token, m_textureSize, m_textureFormat, textureId); + bool result = manager->requestTexture(token, m_textureSize, m_textureFormat); if (result) manager->allocateTexture(&m_fakeTextureAllocator, token); return result; @@ -116,9 +116,17 @@ TEST_F(TextureManagerTest, requestTextureExceedingPreferredLimit) tokens[i] = textureManager->getToken(); EXPECT_TRUE(requestTexture(textureManager.get(), tokens[i])); EXPECT_TRUE(textureManager->hasTexture(tokens[i])); - textureManager->unprotectTexture(tokens[i]); } + textureManager->unprotectTexture(tokens[4]); + textureManager->unprotectTexture(tokens[5]); + + // These textures should be valid before the reduceMemoryToLimit call. + EXPECT_TRUE(textureManager->hasTexture(tokens[0])); + EXPECT_TRUE(textureManager->hasTexture(tokens[2])); + + textureManager->reduceMemoryToLimit(texturesMemorySize(preferredTextures)); + EXPECT_FALSE(textureManager->hasTexture(tokens[0])); EXPECT_TRUE(textureManager->hasTexture(tokens[1])); EXPECT_TRUE(textureManager->isProtected(tokens[1])); @@ -243,4 +251,50 @@ TEST_F(TextureManagerTest, setPreferredMemoryLimitBytes) EXPECT_EQ(texturesMemorySize(preferredTextures), textureManager->preferredMemoryLimitBytes()); } +TEST_F(TextureManagerTest, textureManagerDestroyedBeforeManagedTexture) +{ + OwnPtr<TextureManager> textureManager = createTextureManager(1, 1); + OwnPtr<ManagedTexture> managedTexture = ManagedTexture::create(textureManager.get()); + + IntSize size(50, 50); + unsigned format = GraphicsContext3D::RGBA; + + // Texture is initially invalid, but we should be able to reserve. + EXPECT_FALSE(managedTexture->isValid(size, format)); + EXPECT_TRUE(managedTexture->reserve(size, format)); + EXPECT_TRUE(managedTexture->isValid(size, format)); + + textureManager.clear(); + + // Deleting the manager should invalidate the texture and reservation attempts should fail. + EXPECT_FALSE(managedTexture->isValid(size, format)); + EXPECT_FALSE(managedTexture->reserve(size, format)); +} + +TEST_F(TextureManagerTest, textureMovedToNewManager) +{ + OwnPtr<TextureManager> textureManagerOne = createTextureManager(1, 1); + OwnPtr<TextureManager> textureManagerTwo = createTextureManager(1, 1); + OwnPtr<ManagedTexture> managedTexture = ManagedTexture::create(textureManagerOne.get()); + + IntSize size(50, 50); + unsigned format = GraphicsContext3D::RGBA; + + // Texture is initially invalid, but we should be able to reserve. + EXPECT_FALSE(managedTexture->isValid(size, format)); + EXPECT_TRUE(managedTexture->reserve(size, format)); + EXPECT_TRUE(managedTexture->isValid(size, format)); + + // Setting to the same manager should be a no-op. + managedTexture->setTextureManager(textureManagerOne.get()); + EXPECT_TRUE(managedTexture->isValid(size, format)); + + // Setting to a different manager should invalidate the texture. + managedTexture->setTextureManager(textureManagerTwo.get()); + + EXPECT_FALSE(managedTexture->isValid(size, format)); + EXPECT_TRUE(managedTexture->reserve(size, format)); + EXPECT_TRUE(managedTexture->isValid(size, format)); +} + } // namespace |