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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/prioritized_resource.h" | 7 #include "cc/prioritized_resource.h" |
8 | 8 |
9 #include "cc/prioritized_resource_manager.h" | 9 #include "cc/prioritized_resource_manager.h" |
10 #include "cc/resource.h" | 10 #include "cc/resource.h" |
11 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread | 11 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread |
12 #include "cc/test/fake_graphics_context.h" | 12 #include "cc/test/fake_graphics_context.h" |
13 #include "cc/test/fake_proxy.h" | 13 #include "cc/test/fake_proxy.h" |
14 #include "cc/test/tiled_layer_test_common.h" | 14 #include "cc/test/tiled_layer_test_common.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 using namespace cc; | |
18 using namespace WebKitTests; | 17 using namespace WebKitTests; |
19 | 18 |
20 namespace cc { | 19 namespace cc { |
21 | 20 |
22 class PrioritizedResourceTest : public testing::Test { | 21 class PrioritizedResourceTest : public testing::Test { |
23 public: | 22 public: |
24 PrioritizedResourceTest() | 23 PrioritizedResourceTest() |
25 : m_proxy(scoped_ptr<Thread>(NULL)) | 24 : m_proxy(scoped_ptr<Thread>(NULL)) |
26 , m_textureSize(256, 256) | 25 , m_textureSize(256, 256) |
27 , m_textureFormat(GL_RGBA) | 26 , m_textureFormat(GL_RGBA) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 90 } |
92 | 91 |
93 protected: | 92 protected: |
94 FakeProxy m_proxy; | 93 FakeProxy m_proxy; |
95 const gfx::Size m_textureSize; | 94 const gfx::Size m_textureSize; |
96 const GLenum m_textureFormat; | 95 const GLenum m_textureFormat; |
97 scoped_ptr<GraphicsContext> m_context; | 96 scoped_ptr<GraphicsContext> m_context; |
98 scoped_ptr<ResourceProvider> m_resourceProvider; | 97 scoped_ptr<ResourceProvider> m_resourceProvider; |
99 }; | 98 }; |
100 | 99 |
101 } | |
102 | |
103 namespace { | 100 namespace { |
104 | 101 |
105 TEST_F(PrioritizedResourceTest, requestTextureExceedingMaxLimit) | 102 TEST_F(PrioritizedResourceTest, requestTextureExceedingMaxLimit) |
106 { | 103 { |
107 const size_t maxTextures = 8; | 104 const size_t maxTextures = 8; |
108 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe
xtures); | 105 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe
xtures); |
109 | 106 |
110 // Create textures for double our memory limit. | 107 // Create textures for double our memory limit. |
111 scoped_ptr<PrioritizedResource> textures[maxTextures*2]; | 108 scoped_ptr<PrioritizedResource> textures[maxTextures*2]; |
112 | 109 |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 resourceManager->pushTexturePrioritiesToBackings(); | 694 resourceManager->pushTexturePrioritiesToBackings(); |
698 EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes()); | 695 EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes()); |
699 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes()); | 696 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes()); |
700 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearby
Bytes()); | 697 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearby
Bytes()); |
701 } | 698 } |
702 | 699 |
703 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(
&m_proxy); | 700 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(
&m_proxy); |
704 resourceManager->clearAllMemory(resourceProvider()); | 701 resourceManager->clearAllMemory(resourceProvider()); |
705 } | 702 } |
706 | 703 |
707 | 704 } // namespace |
708 } // anonymous namespace | 705 } // namespace cc |
OLD | NEW |