| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/prioritized_resource.h" | 5 #include "cc/prioritized_resource.h" |
| 6 | 6 |
| 7 #include "cc/prioritized_resource_manager.h" | 7 #include "cc/prioritized_resource_manager.h" |
| 8 #include "cc/resource.h" | 8 #include "cc/resource.h" |
| 9 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread | 9 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread |
| 10 #include "cc/test/fake_output_surface.h" | 10 #include "cc/test/fake_graphics_context.h" |
| 11 #include "cc/test/fake_proxy.h" | 11 #include "cc/test/fake_proxy.h" |
| 12 #include "cc/test/tiled_layer_test_common.h" | 12 #include "cc/test/tiled_layer_test_common.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 using namespace WebKitTests; | 15 using namespace WebKitTests; |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 | 18 |
| 19 class PrioritizedResourceTest : public testing::Test { | 19 class PrioritizedResourceTest : public testing::Test { |
| 20 public: | 20 public: |
| 21 PrioritizedResourceTest() | 21 PrioritizedResourceTest() |
| 22 : m_proxy(scoped_ptr<Thread>(NULL)) | 22 : m_proxy(scoped_ptr<Thread>(NULL)) |
| 23 , m_textureSize(256, 256) | 23 , m_textureSize(256, 256) |
| 24 , m_textureFormat(GL_RGBA) | 24 , m_textureFormat(GL_RGBA) |
| 25 , m_outputSurface(createFakeOutputSurface()) | 25 , m_context(WebKit::createFakeGraphicsContext()) |
| 26 { | 26 { |
| 27 DebugScopedSetImplThread implThread(&m_proxy); | 27 DebugScopedSetImplThread implThread(&m_proxy); |
| 28 m_resourceProvider = ResourceProvider::create(m_outputSurface.get()); | 28 m_resourceProvider = ResourceProvider::create(m_context.get()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 virtual ~PrioritizedResourceTest() | 31 virtual ~PrioritizedResourceTest() |
| 32 { | 32 { |
| 33 DebugScopedSetImplThread implThread(&m_proxy); | 33 DebugScopedSetImplThread implThread(&m_proxy); |
| 34 m_resourceProvider.reset(); | 34 m_resourceProvider.reset(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 size_t texturesMemorySize(size_t textureCount) | 37 size_t texturesMemorySize(size_t textureCount) |
| 38 { | 38 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 size_t evictedBackingCount(PrioritizedResourceManager* resourceManager) | 92 size_t evictedBackingCount(PrioritizedResourceManager* resourceManager) |
| 93 { | 93 { |
| 94 return resourceManager->m_evictedBackings.size(); | 94 return resourceManager->m_evictedBackings.size(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 protected: | 97 protected: |
| 98 FakeProxy m_proxy; | 98 FakeProxy m_proxy; |
| 99 const gfx::Size m_textureSize; | 99 const gfx::Size m_textureSize; |
| 100 const GLenum m_textureFormat; | 100 const GLenum m_textureFormat; |
| 101 scoped_ptr<OutputSurface> m_outputSurface; | 101 scoped_ptr<GraphicsContext> m_context; |
| 102 scoped_ptr<ResourceProvider> m_resourceProvider; | 102 scoped_ptr<ResourceProvider> m_resourceProvider; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 namespace { | 105 namespace { |
| 106 | 106 |
| 107 TEST_F(PrioritizedResourceTest, requestTextureExceedingMaxLimit) | 107 TEST_F(PrioritizedResourceTest, requestTextureExceedingMaxLimit) |
| 108 { | 108 { |
| 109 const size_t maxTextures = 8; | 109 const size_t maxTextures = 8; |
| 110 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe
xtures); | 110 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe
xtures); |
| 111 | 111 |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes()); | 700 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes()); |
| 701 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearby
Bytes()); | 701 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearby
Bytes()); |
| 702 } | 702 } |
| 703 | 703 |
| 704 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(
&m_proxy); | 704 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(
&m_proxy); |
| 705 resourceManager->clearAllMemory(resourceProvider()); | 705 resourceManager->clearAllMemory(resourceProvider()); |
| 706 } | 706 } |
| 707 | 707 |
| 708 } // namespace | 708 } // namespace |
| 709 } // namespace cc | 709 } // namespace cc |
| OLD | NEW |