Chromium Code Reviews| Index: cc/CCTextureUpdateControllerTest.cpp |
| diff --git a/cc/CCTextureUpdateControllerTest.cpp b/cc/CCTextureUpdateControllerTest.cpp |
| index 418aeb3079a3ef14714c063e8e0faee2dcd55a26..094929f406c6b8fe861b4c1f60547f13b15206c2 100644 |
| --- a/cc/CCTextureUpdateControllerTest.cpp |
| +++ b/cc/CCTextureUpdateControllerTest.cpp |
| @@ -67,8 +67,12 @@ private: |
| class TextureForUploadTest : public LayerTextureUpdater::Texture { |
| public: |
| - TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritizedTexture>(0)) { } |
| + TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritizedTexture>(0)), m_evicted(false) { } |
|
jamesr
2012/09/19 18:56:37
one initialization per line, please. I think this
ccameron
2012/09/19 20:52:02
Fixed.
|
| virtual void updateRect(CCResourceProvider*, const IntRect& sourceRect, const IntSize& destOffset) { } |
| + virtual bool backingResourceWasEvicted() const { return m_evicted; } |
| + void evictBackingResource() { m_evicted = true; } |
| +private: |
| + bool m_evicted; |
| }; |
| @@ -157,28 +161,39 @@ protected: |
| m_resourceProvider = CCResourceProvider::create(m_context.get(), UnthrottledUploader); |
| } |
| - void appendFullUploadsToUpdateQueue(int count) |
| + |
| + void appendFullUploadsOfIndexedTextureToUpdateQueue(int count, int textureIndex) |
| { |
| m_fullUploadCountExpected += count; |
| m_totalUploadCountExpected += count; |
| const IntRect rect(0, 0, 300, 150); |
| - const TextureUploader::Parameters upload = { &m_texture, rect, IntSize() }; |
| + const TextureUploader::Parameters upload = { &m_textures[textureIndex], rect, IntSize() }; |
| for (int i = 0; i < count; i++) |
| m_queue->appendFullUpload(upload); |
| } |
| - void appendPartialUploadsToUpdateQueue(int count) |
| + void appendFullUploadsToUpdateQueue(int count) |
| + { |
| + appendFullUploadsOfIndexedTextureToUpdateQueue(count, 0); |
| + } |
| + |
| + void appendPartialUploadsOfIndexedTextureToUpdateQueue(int count, int textureIndex) |
| { |
| m_partialCountExpected += count; |
| m_totalUploadCountExpected += count; |
| const IntRect rect(0, 0, 100, 100); |
| - const TextureUploader::Parameters upload = { &m_texture, rect, IntSize() }; |
| + const TextureUploader::Parameters upload = { &m_textures[textureIndex], rect, IntSize() }; |
| for (int i = 0; i < count; i++) |
| m_queue->appendPartialUpload(upload); |
| } |
| + void appendPartialUploadsToUpdateQueue(int count) |
| + { |
| + appendPartialUploadsOfIndexedTextureToUpdateQueue(count, 0); |
| + } |
| + |
| void setMaxUploadCountPerUpdate(int count) |
| { |
| m_maxUploadCountPerUpdate = count; |
| @@ -189,7 +204,7 @@ protected: |
| OwnPtr<CCGraphicsContext> m_context; |
| OwnPtr<CCResourceProvider> m_resourceProvider; |
| OwnPtr<CCTextureUpdateQueue> m_queue; |
| - TextureForUploadTest m_texture; |
| + TextureForUploadTest m_textures[4]; |
| TextureUploaderForUploadTest m_uploader; |
| OwnPtr<WebThread> m_thread; |
| WebCompositorInitializer m_compositorInitializer; |
| @@ -490,4 +505,37 @@ TEST_F(CCTextureUpdateControllerTest, UpdatesCompleteInFiniteTime) |
| EXPECT_EQ(2, m_numTotalUploads); |
| } |
| +TEST_F(CCTextureUpdateControllerTest, ClearUploadsToEvictedResources) |
| +{ |
| + appendFullUploadsOfIndexedTextureToUpdateQueue(1, 0); |
| + appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 1); |
| + appendFullUploadsOfIndexedTextureToUpdateQueue(1, 2); |
| + appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 3); |
| + DebugScopedSetImplThread implThread; |
| + |
| + m_queue->clearUploadsToEvictedResources(); |
| + EXPECT_EQ(2u, m_queue->fullUploadSize()); |
| + EXPECT_EQ(2u, m_queue->partialUploadSize()); |
| + |
| + m_textures[0].evictBackingResource(); |
| + m_queue->clearUploadsToEvictedResources(); |
| + EXPECT_EQ(1u, m_queue->fullUploadSize()); |
| + EXPECT_EQ(2u, m_queue->partialUploadSize()); |
| + |
| + m_textures[3].evictBackingResource(); |
| + m_queue->clearUploadsToEvictedResources(); |
| + EXPECT_EQ(1u, m_queue->fullUploadSize()); |
| + EXPECT_EQ(1u, m_queue->partialUploadSize()); |
| + |
| + m_textures[2].evictBackingResource(); |
| + m_queue->clearUploadsToEvictedResources(); |
| + EXPECT_EQ(0u, m_queue->fullUploadSize()); |
| + EXPECT_EQ(1u, m_queue->partialUploadSize()); |
| + |
| + m_textures[1].evictBackingResource(); |
| + m_queue->clearUploadsToEvictedResources(); |
| + EXPECT_EQ(0u, m_queue->fullUploadSize()); |
| + EXPECT_EQ(0u, m_queue->partialUploadSize()); |
| +} |
| + |
| } // namespace |