Changeset 106243 in webkit


Ignore:
Timestamp:
Jan 30, 2012 7:24:22 AM (12 years ago)
Author:
jochen@chromium.org
Message:

[chromium] remove exit time destructors from TextureManagerTest
https://bugs.webkit.org/show_bug.cgi?id=77333

Reviewed by Tony Gentilcore.

Non-trivial, global objects require an at-exit time destructor which add
unnecessary complexity and delays to shutdown.

  • tests/FakeCCLayerTreeHostClient.h: added newline at EOF
  • tests/TextureManagerTest.cpp:

(WTF::FakeTextureAllocator::~FakeTextureAllocator):
(TextureManagerTest):
(WTF::TextureManagerTest::TextureManagerTest):
(WTF::TextureManagerTest::~TextureManagerTest):
(WTF::TextureManagerTest::texturesMemorySize):
(WTF::TextureManagerTest::createTextureManager):
(WTF::TextureManagerTest::requestTexture):
(WTF::TEST_F):

Location:
trunk/Source/WebKit/chromium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r106223 r106243  
     12012-01-30  Jochen Eisinger  <jochen@chromium.org>
     2
     3        [chromium] remove exit time destructors from TextureManagerTest
     4        https://bugs.webkit.org/show_bug.cgi?id=77333
     5
     6        Reviewed by Tony Gentilcore.
     7
     8        Non-trivial, global objects require an at-exit time destructor which add
     9        unnecessary complexity and delays to shutdown.
     10
     11        * tests/FakeCCLayerTreeHostClient.h: added newline at EOF
     12        * tests/TextureManagerTest.cpp:
     13        (WTF::FakeTextureAllocator::~FakeTextureAllocator):
     14        (TextureManagerTest):
     15        (WTF::TextureManagerTest::TextureManagerTest):
     16        (WTF::TextureManagerTest::~TextureManagerTest):
     17        (WTF::TextureManagerTest::texturesMemorySize):
     18        (WTF::TextureManagerTest::createTextureManager):
     19        (WTF::TextureManagerTest::requestTexture):
     20        (WTF::TEST_F):
     21
    1222012-01-30  Hans Wennborg  <hans@chromium.org>
    223
  • trunk/Source/WebKit/chromium/tests/TextureManagerTest.cpp

    r104474 r106243  
    3636class FakeTextureAllocator : public TextureAllocator {
    3737public:
     38    virtual ~FakeTextureAllocator() { }
    3839    virtual unsigned createTexture(const IntSize&, GC3Denum) { return 1; }
    3940    virtual void deleteTexture(unsigned, const IntSize&, GC3Denum) { }
    4041};
    4142
    42 FakeTextureAllocator fakeTextureAllocator;
    43 const IntSize textureSize(256, 256);
    44 const GC3Denum textureFormat = GraphicsContext3D::RGBA;
    45 
    46 size_t texturesMemorySize(size_t textureCount)
    47 {
    48     return TextureManager::memoryUseBytes(textureSize, textureFormat) * textureCount;
    49 }
    50 
    51 PassOwnPtr<TextureManager> createTextureManager(size_t maxTextures, size_t preferredTextures)
    52 {
    53     return TextureManager::create(texturesMemorySize(maxTextures), texturesMemorySize(preferredTextures), 1024);
    54 }
    55 
    56 bool requestTexture(TextureManager* manager, TextureToken token)
    57 {
    58     unsigned textureId;
    59     bool result = manager->requestTexture(token, textureSize, textureFormat, textureId);
    60     if (result)
    61         manager->allocateTexture(&fakeTextureAllocator, token);
    62     return result;
    63 }
    64 
    65 TEST(TextureManagerTest, requestTextureInPreferredLimit)
     43class TextureManagerTest : public testing::Test {
     44public:
     45    TextureManagerTest()
     46        : m_textureSize(256, 256)
     47        , m_textureFormat(GraphicsContext3D::RGBA)
     48    {
     49    }
     50
     51    virtual ~TextureManagerTest()
     52    {
     53    }
     54
     55    size_t texturesMemorySize(size_t textureCount)
     56    {
     57        return TextureManager::memoryUseBytes(m_textureSize, m_textureFormat) * textureCount;
     58    }
     59
     60    PassOwnPtr<TextureManager> createTextureManager(size_t maxTextures, size_t preferredTextures)
     61    {
     62        return TextureManager::create(texturesMemorySize(maxTextures), texturesMemorySize(preferredTextures), 1024);
     63    }
     64
     65    bool requestTexture(TextureManager* manager, TextureToken token)
     66    {
     67        unsigned textureId;
     68        bool result = manager->requestTexture(token, m_textureSize, m_textureFormat, textureId);
     69        if (result)
     70            manager->allocateTexture(&m_fakeTextureAllocator, token);
     71        return result;
     72    }
     73
     74private:
     75    FakeTextureAllocator m_fakeTextureAllocator;
     76    const IntSize m_textureSize;
     77    const GC3Denum m_textureFormat;
     78};
     79
     80TEST_F(TextureManagerTest, requestTextureInPreferredLimit)
    6681{
    6782    const size_t preferredTextures = 8;
     
    8398}
    8499
    85 TEST(TextureManagerTest, requestTextureExceedingPreferredLimit)
     100TEST_F(TextureManagerTest, requestTextureExceedingPreferredLimit)
    86101{
    87102    const size_t maxTextures = 8;
     
    115130}
    116131
    117 TEST(TextureManagerTest, requestTextureExceedingMaxLimit)
     132TEST_F(TextureManagerTest, requestTextureExceedingMaxLimit)
    118133{
    119134    const size_t maxTextures = 8;
     
    147162}
    148163
    149 TEST(TextureManagerTest, reduceMemoryToLimit)
     164TEST_F(TextureManagerTest, reduceMemoryToLimit)
    150165{
    151166    const size_t maxTextures = 8;
     
    180195}
    181196
    182 TEST(TextureManagerTest, setMaxMemoryLimitBytes)
     197TEST_F(TextureManagerTest, setMaxMemoryLimitBytes)
    183198{
    184199    const size_t maxTextures = 8;
     
    204219}
    205220
    206 TEST(TextureManagerTest, setPreferredMemoryLimitBytes)
     221TEST_F(TextureManagerTest, setPreferredMemoryLimitBytes)
    207222{
    208223    const size_t maxTextures = 8;
Note: See TracChangeset for help on using the changeset viewer.