Index: content/common/gpu/gpu_memory_manager_unittest.cc |
diff --git a/content/common/gpu/gpu_memory_manager_unittest.cc b/content/common/gpu/gpu_memory_manager_unittest.cc |
index 567ee25bf12cca61c721de123439bd8a496409d1..c2fb527d7015dda559a85e8945c5eb7a36ef90b4 100644 |
--- a/content/common/gpu/gpu_memory_manager_unittest.cc |
+++ b/content/common/gpu/gpu_memory_manager_unittest.cc |
@@ -107,11 +107,6 @@ class FakeClient : public GpuMemoryManagerClient { |
memory_tracker_ = NULL; |
} |
- void SetMemoryAllocation(const MemoryAllocation& alloc) override { |
- allocation_ = alloc; |
- ClientAssignmentCollector::AddClientStat(this, alloc); |
- } |
- |
void SuggestHaveFrontBuffer(bool suggest_have_frontbuffer) override { |
suggest_have_frontbuffer_ = suggest_have_frontbuffer; |
} |
@@ -192,216 +187,4 @@ class GpuMemoryManagerTest : public testing::Test { |
GpuMemoryManager memmgr_; |
}; |
-// Test GpuMemoryManager::Manage basic functionality. |
-// Expect memory allocation to set suggest_have_frontbuffer/backbuffer |
-// according to visibility and last used time for stubs with surface. |
-// Expect memory allocation to be shared according to share groups for stubs |
-// without a surface. |
-TEST_F(GpuMemoryManagerTest, TestManageBasicFunctionality) { |
- // Test stubs with surface. |
- FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub2(&memmgr_, GenerateUniqueSurfaceId(), false); |
- |
- Manage(); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub2.allocation_)); |
- |
- // Test stubs without surface, with share group of 1 stub. |
- FakeClient stub3(&memmgr_, &stub1), stub4(&memmgr_, &stub2); |
- |
- Manage(); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub4.allocation_)); |
- |
- // Test stub without surface, with share group of multiple stubs. |
- FakeClient stub5(&memmgr_ , &stub2); |
- |
- Manage(); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub4.allocation_)); |
-} |
- |
-// Test GpuMemoryManager::Manage functionality: changing visibility. |
-// Expect memory allocation to set suggest_have_frontbuffer/backbuffer |
-// according to visibility and last used time for stubs with surface. |
-// Expect memory allocation to be shared according to share groups for stubs |
-// without a surface. |
-TEST_F(GpuMemoryManagerTest, TestManageChangingVisibility) { |
- FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub2(&memmgr_, GenerateUniqueSurfaceId(), false); |
- |
- FakeClient stub3(&memmgr_, &stub1), stub4(&memmgr_, &stub2); |
- FakeClient stub5(&memmgr_ , &stub2); |
- |
- Manage(); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub4.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub5.allocation_)); |
- |
- stub1.SetVisible(false); |
- stub2.SetVisible(true); |
- |
- Manage(); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub4.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub5.allocation_)); |
-} |
- |
-// Test GpuMemoryManager::Manage functionality: Test more than threshold number |
-// of visible stubs. |
-// Expect all allocations to continue to have frontbuffer. |
-TEST_F(GpuMemoryManagerTest, TestManageManyVisibleStubs) { |
- FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub2(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub3(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub4(&memmgr_, GenerateUniqueSurfaceId(), true); |
- |
- FakeClient stub5(&memmgr_ , &stub1), stub6(&memmgr_ , &stub2); |
- FakeClient stub7(&memmgr_ , &stub2); |
- |
- Manage(); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub4.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub5.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub6.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub7.allocation_)); |
-} |
- |
-// Test GpuMemoryManager::Manage functionality: Test more than threshold number |
-// of not visible stubs. |
-// Expect the stubs surpassing the threshold to not have a backbuffer. |
-TEST_F(GpuMemoryManagerTest, TestManageManyNotVisibleStubs) { |
- FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub2(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub3(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub4(&memmgr_, GenerateUniqueSurfaceId(), true); |
- stub4.SetVisible(false); |
- stub3.SetVisible(false); |
- stub2.SetVisible(false); |
- stub1.SetVisible(false); |
- |
- FakeClient stub5(&memmgr_ , &stub1), stub6(&memmgr_ , &stub4); |
- FakeClient stub7(&memmgr_ , &stub1); |
- |
- Manage(); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub4.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub5.allocation_)); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub6.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub7.allocation_)); |
-} |
- |
-// Test GpuMemoryManager::Manage functionality: Test changing the last used |
-// time of stubs when doing so causes change in which stubs surpass threshold. |
-// Expect frontbuffer to be dropped for the older stub. |
-TEST_F(GpuMemoryManagerTest, TestManageChangingLastUsedTime) { |
- FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub2(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub3(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub4(&memmgr_, GenerateUniqueSurfaceId(), true); |
- |
- FakeClient stub5(&memmgr_ , &stub3), stub6(&memmgr_ , &stub4); |
- FakeClient stub7(&memmgr_ , &stub3); |
- |
- // Make stub4 be the least-recently-used client |
- stub4.SetVisible(false); |
- stub3.SetVisible(false); |
- stub2.SetVisible(false); |
- stub1.SetVisible(false); |
- |
- Manage(); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub4.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub5.allocation_)); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub6.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub7.allocation_)); |
- |
- // Make stub3 become the least-recently-used client. |
- stub2.SetVisible(true); |
- stub2.SetVisible(false); |
- stub4.SetVisible(true); |
- stub4.SetVisible(false); |
- |
- Manage(); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub4.allocation_)); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub5.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub6.allocation_)); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub7.allocation_)); |
-} |
- |
-// Test GpuMemoryManager::Manage functionality: Test changing importance of |
-// enough stubs so that every stub in share group crosses threshold. |
-// Expect memory allocation of the stubs without surface to share memory |
-// allocation with the most visible stub in share group. |
-TEST_F(GpuMemoryManagerTest, TestManageChangingImportanceShareGroup) { |
- FakeClient stub_ignore_a(&memmgr_, GenerateUniqueSurfaceId(), true), |
- stub_ignore_b(&memmgr_, GenerateUniqueSurfaceId(), false), |
- stub_ignore_c(&memmgr_, GenerateUniqueSurfaceId(), false); |
- FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), false), |
- stub2(&memmgr_, GenerateUniqueSurfaceId(), false); |
- |
- FakeClient stub3(&memmgr_, &stub2), stub4(&memmgr_, &stub2); |
- |
- // stub1 and stub2 keep their non-hibernated state because they're |
- // either visible or the 2 most recently used clients (through the |
- // first three checks). |
- stub1.SetVisible(true); |
- stub2.SetVisible(true); |
- Manage(); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub4.allocation_)); |
- |
- stub1.SetVisible(false); |
- Manage(); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub4.allocation_)); |
- |
- stub2.SetVisible(false); |
- Manage(); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub4.allocation_)); |
- |
- // stub_ignore_b will cause stub1 to become hibernated (because |
- // stub_ignore_a, stub_ignore_b, and stub2 are all non-hibernated and more |
- // important). |
- stub_ignore_b.SetVisible(true); |
- stub_ignore_b.SetVisible(false); |
- Manage(); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub4.allocation_)); |
- |
- // stub_ignore_c will cause stub2 to become hibernated (because |
- // stub_ignore_a, stub_ignore_b, and stub_ignore_c are all non-hibernated |
- // and more important). |
- stub_ignore_c.SetVisible(true); |
- stub_ignore_c.SetVisible(false); |
- Manage(); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub1.allocation_)); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub2.allocation_)); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub3.allocation_)); |
- EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub4.allocation_)); |
-} |
- |
} // namespace content |