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 4153d62909881f7140b9fa2c16a567c8af680fc5..61de4b93163e546ec1797057cb1c61d1a5ec3bcd 100644 |
--- a/content/common/gpu/gpu_memory_manager_unittest.cc |
+++ b/content/common/gpu/gpu_memory_manager_unittest.cc |
@@ -783,6 +783,12 @@ TEST_F(GpuMemoryManagerTest, TestBackgroundMru) { |
memmgr_.TestingSetAvailableGpuMemory(64); |
memmgr_.TestingSetNonvisibleAvailableGpuMemory(16); |
+ uint64 bytes_when_not_visible_expected = |
+ memmgr_.GetCurrentNonvisibleAvailableGpuMemory(); |
+#if defined (OS_ANDROID) |
+ bytes_when_not_visible_expected = 0; |
+#endif |
+ |
FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); |
FakeClient stub2(&memmgr_, GenerateUniqueSurfaceId(), true); |
FakeClient stub3(&memmgr_, GenerateUniqueSurfaceId(), true); |
@@ -795,26 +801,25 @@ TEST_F(GpuMemoryManagerTest, TestBackgroundMru) { |
Manage(); |
EXPECT_EQ(memmgr_.bytes_nonvisible_available_gpu_memory_, |
memmgr_.GetCurrentNonvisibleAvailableGpuMemory()); |
- EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), |
- stub1.BytesWhenNotVisible()); |
- EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), |
- stub2.BytesWhenNotVisible()); |
- EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), |
- stub3.BytesWhenNotVisible()); |
- |
+ EXPECT_EQ(stub1.BytesWhenNotVisible(), |
+ bytes_when_not_visible_expected); |
+ EXPECT_EQ(stub2.BytesWhenNotVisible(), |
+ bytes_when_not_visible_expected); |
+ EXPECT_EQ(stub3.BytesWhenNotVisible(), |
+ bytes_when_not_visible_expected); |
// Background stubs 1 and 2, and they should fit |
stub2.SetVisible(false); |
stub1.SetVisible(false); |
Manage(); |
EXPECT_EQ(memmgr_.bytes_nonvisible_available_gpu_memory_, |
- memmgr_.GetCurrentNonvisibleAvailableGpuMemory()); |
- EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), |
- stub1.BytesWhenNotVisible()); |
- EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), |
- stub2.BytesWhenNotVisible()); |
- EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), |
- stub3.BytesWhenNotVisible()); |
+ bytes_when_not_visible_expected); |
+ EXPECT_EQ(stub1.BytesWhenNotVisible(), |
+ bytes_when_not_visible_expected); |
+ EXPECT_EQ(stub2.BytesWhenNotVisible(), |
+ bytes_when_not_visible_expected); |
+ EXPECT_EQ(stub3.BytesWhenNotVisible(), |
+ bytes_when_not_visible_expected); |
// Now background stub 3, and it should cause stub 2 to be |
// evicted because it was set non-visible first |
@@ -822,12 +827,12 @@ TEST_F(GpuMemoryManagerTest, TestBackgroundMru) { |
Manage(); |
EXPECT_EQ(memmgr_.bytes_nonvisible_available_gpu_memory_, |
memmgr_.GetCurrentNonvisibleAvailableGpuMemory()); |
- EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), |
- stub1.BytesWhenNotVisible()); |
- EXPECT_EQ(0ul, |
- stub2.BytesWhenNotVisible()); |
- EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), |
- stub3.BytesWhenNotVisible()); |
+ EXPECT_EQ(stub1.BytesWhenNotVisible(), |
+ bytes_when_not_visible_expected); |
+ EXPECT_EQ(stub2.BytesWhenNotVisible(), |
+ 0ul); |
+ EXPECT_EQ(stub3.BytesWhenNotVisible(), |
+ bytes_when_not_visible_expected); |
} |
// Test GpuMemoryManager's tracking of unmanaged (e.g, WebGL) memory. |
@@ -894,6 +899,11 @@ TEST_F(GpuMemoryManagerTestNonuniform, BackgroundMru) { |
memmgr_.TestingSetNonvisibleAvailableGpuMemory(16); |
memmgr_.TestingSetMinimumClientAllocation(8); |
+ uint64 bytes_when_not_visible_expected = 6u; |
+#if defined (OS_ANDROID) |
+ bytes_when_not_visible_expected = 0; |
+#endif |
+ |
FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); |
FakeClient stub2(&memmgr_, GenerateUniqueSurfaceId(), true); |
FakeClient stub3(&memmgr_, GenerateUniqueSurfaceId(), true); |
@@ -910,9 +920,9 @@ TEST_F(GpuMemoryManagerTestNonuniform, BackgroundMru) { |
EXPECT_LT(stub1.BytesWhenVisible(), 22u); |
EXPECT_LT(stub2.BytesWhenVisible(), 22u); |
EXPECT_LT(stub3.BytesWhenVisible(), 22u); |
- EXPECT_GE(stub1.BytesWhenNotVisible(), 6u); |
- EXPECT_GE(stub2.BytesWhenNotVisible(), 6u); |
- EXPECT_GE(stub3.BytesWhenNotVisible(), 6u); |
+ EXPECT_GE(stub1.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
+ EXPECT_GE(stub2.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
+ EXPECT_GE(stub3.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
// Background stubs 1 and 2, and they should fit. All stubs should |
// have their full nicetohave budget should they become visible. |
@@ -924,18 +934,17 @@ TEST_F(GpuMemoryManagerTestNonuniform, BackgroundMru) { |
EXPECT_GE(stub3.BytesWhenVisible(), 23u); |
EXPECT_LT(stub1.BytesWhenVisible(), 32u); |
EXPECT_LT(stub2.BytesWhenVisible(), 32u); |
- EXPECT_LT(stub3.BytesWhenVisible(), 32u); |
- EXPECT_GE(stub1.BytesWhenNotVisible(), 6u); |
- EXPECT_GE(stub2.BytesWhenNotVisible(), 6u); |
- EXPECT_GE(stub3.BytesWhenNotVisible(), 6u); |
+ EXPECT_GE(stub1.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
+ EXPECT_GE(stub2.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
+ EXPECT_GE(stub3.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
// Now background stub 3, and it should cause stub 2 to be |
// evicted because it was set non-visible first |
stub3.SetVisible(false); |
Manage(); |
- EXPECT_GE(stub1.BytesWhenNotVisible(), 6u); |
+ EXPECT_GE(stub1.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
EXPECT_EQ(stub2.BytesWhenNotVisible(), 0u); |
- EXPECT_GE(stub3.BytesWhenNotVisible(), 6u); |
+ EXPECT_GE(stub3.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
} |
// Test that once a backgrounded client has dropped its resources, it |
@@ -947,6 +956,11 @@ TEST_F(GpuMemoryManagerTestNonuniform, BackgroundDiscardPersistent) { |
memmgr_.TestingSetNonvisibleAvailableGpuMemory(16); |
memmgr_.TestingSetMinimumClientAllocation(8); |
+ uint64 bytes_when_not_visible_expected = 10ul; |
+#if defined (OS_ANDROID) |
+ bytes_when_not_visible_expected = 0; |
+#endif |
+ |
FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); |
FakeClient stub2(&memmgr_, GenerateUniqueSurfaceId(), true); |
@@ -955,8 +969,8 @@ TEST_F(GpuMemoryManagerTestNonuniform, BackgroundDiscardPersistent) { |
SetClientStats(&stub1, 10, 20); |
SetClientStats(&stub2, 10, 20); |
Manage(); |
- EXPECT_GE(stub1.BytesWhenNotVisible(), 10u); |
- EXPECT_GE(stub2.BytesWhenNotVisible(), 10u); |
+ EXPECT_GE(stub1.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
+ EXPECT_GE(stub2.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
// If they both go nonvisible, then only the most recently used client |
// should keep its contents. |
@@ -964,16 +978,16 @@ TEST_F(GpuMemoryManagerTestNonuniform, BackgroundDiscardPersistent) { |
stub2.SetVisible(false); |
Manage(); |
EXPECT_EQ(stub1.BytesWhenNotVisible(), 0u); |
- EXPECT_GE(stub2.BytesWhenNotVisible(), 10u); |
+ EXPECT_GE(stub2.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
// When becoming visible, stub 2 should get its contents back, and |
// retain them next time it is made nonvisible. |
stub2.SetVisible(true); |
Manage(); |
- EXPECT_GE(stub2.BytesWhenNotVisible(), 10u); |
+ EXPECT_GE(stub2.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
stub2.SetVisible(false); |
Manage(); |
- EXPECT_GE(stub2.BytesWhenNotVisible(), 10u); |
+ EXPECT_GE(stub2.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
} |
// Test tracking of unmanaged (e.g, WebGL) memory. |
@@ -1041,10 +1055,10 @@ TEST_F(GpuMemoryManagerTestNonuniform, DefaultAllocation) { |
FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); |
- // Expect that a client which has not sent stats receive the |
- // default allocation. |
+ // Expect that a client which has not sent stats receive at |
+ // least the default allocation. |
Manage(); |
- EXPECT_EQ(stub1.BytesWhenVisible(), |
+ EXPECT_GE(stub1.BytesWhenVisible(), |
memmgr_.GetDefaultClientAllocation()); |
EXPECT_EQ(stub1.BytesWhenNotVisible(), 0u); |
} |