Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1987)

Unified Diff: content/common/gpu/gpu_memory_manager_unittest.cc

Issue 10083056: GpuMemoryManager suggests values for renderer Contents Texture Managers' preferred memory limit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing issue with every proxy registering a callback, even when it is null. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 501e481c7cf05bc3d36c76b3dc5c270f37ba989d..1933c60693ff22f8041933156a1f8118335189e2 100644
--- a/content/common/gpu/gpu_memory_manager_unittest.cc
+++ b/content/common/gpu/gpu_memory_manager_unittest.cc
@@ -23,6 +23,9 @@ class FakeCommandBufferStub : public GpuCommandBufferStubBase {
: surface_state_(surface_id, visible, last_used_time) {
}
+ virtual bool handles_memory_allocations() const {
+ return true;
+ }
virtual bool has_surface_state() const {
return surface_state_.surface_id != 0;
}
@@ -198,8 +201,10 @@ TEST_F(GpuMemoryManagerTest, TestManageBasicFunctionality) {
client_.stubs_.push_back(&stub4);
Manage();
- EXPECT_EQ(stub1.allocation_, stub3.allocation_);
- EXPECT_EQ(stub2.allocation_, stub4.allocation_);
+ EXPECT_GT(stub1.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_EQ(stub2.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_GT(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
// Test stub without surface, with share group of multiple stubs.
FakeCommandBufferStubWithoutSurface stub5;
@@ -208,7 +213,7 @@ TEST_F(GpuMemoryManagerTest, TestManageBasicFunctionality) {
client_.stubs_.push_back(&stub5);
Manage();
- EXPECT_EQ(stub1.allocation_, stub5.allocation_);
+ EXPECT_GT(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
}
// Test GpuMemoryManager::Manage functionality: changing visibility.
@@ -238,9 +243,11 @@ TEST_F(GpuMemoryManagerTest, TestManageChangingVisibility) {
EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, true);
EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false);
- EXPECT_EQ(stub1.allocation_, stub3.allocation_);
- EXPECT_EQ(stub2.allocation_, stub4.allocation_);
- EXPECT_EQ(stub1.allocation_, stub5.allocation_);
+ EXPECT_GT(stub1.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_EQ(stub2.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_GT(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
stub1.surface_state_.visible = false;
stub2.surface_state_.visible = true;
@@ -250,9 +257,11 @@ TEST_F(GpuMemoryManagerTest, TestManageChangingVisibility) {
EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false);
EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, true);
- EXPECT_EQ(stub1.allocation_, stub3.allocation_);
- EXPECT_EQ(stub2.allocation_, stub4.allocation_);
- EXPECT_EQ(stub2.allocation_, stub5.allocation_);
+ EXPECT_EQ(stub1.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_GT(stub2.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
}
// Test GpuMemoryManager::Manage functionality: Test more than threshold number
@@ -288,9 +297,9 @@ TEST_F(GpuMemoryManagerTest, TestManageManyVisibleStubs) {
EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, true);
EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, true);
EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, true);
- EXPECT_EQ(stub5.allocation_, stub1.allocation_);
- EXPECT_EQ(stub6.allocation_, stub2.allocation_);
- EXPECT_EQ(stub7.allocation_, stub1.allocation_);
+ EXPECT_GT(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub6.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub7.allocation_.gpu_resource_size_in_bytes, 1ul);
}
// Test GpuMemoryManager::Manage functionality: Test more than threshold number
@@ -326,9 +335,9 @@ TEST_F(GpuMemoryManagerTest, TestManageManyNotVisibleStubs) {
EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, false);
EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, false);
EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, false);
- EXPECT_EQ(stub5.allocation_, stub1.allocation_);
- EXPECT_EQ(stub6.allocation_, stub4.allocation_);
- EXPECT_EQ(stub7.allocation_, stub1.allocation_);
+ EXPECT_GT(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_EQ(stub6.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_GT(stub7.allocation_.gpu_resource_size_in_bytes, 1ul);
}
// Test GpuMemoryManager::Manage functionality: Test changing the last used
@@ -360,9 +369,9 @@ TEST_F(GpuMemoryManagerTest, TestManageChangingLastUsedTime) {
EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, false);
EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, false);
EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, false);
- EXPECT_EQ(stub5.allocation_, stub3.allocation_);
- EXPECT_EQ(stub6.allocation_, stub4.allocation_);
- EXPECT_EQ(stub7.allocation_, stub3.allocation_);
+ EXPECT_GT(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_EQ(stub6.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_GT(stub7.allocation_.gpu_resource_size_in_bytes, 1ul);
stub3.surface_state_.last_used_time = older_;
stub4.surface_state_.last_used_time = newer_;
@@ -372,9 +381,9 @@ TEST_F(GpuMemoryManagerTest, TestManageChangingLastUsedTime) {
EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, false);
EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, true);
EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, false);
- EXPECT_EQ(stub5.allocation_, stub3.allocation_);
- EXPECT_EQ(stub6.allocation_, stub4.allocation_);
- EXPECT_EQ(stub7.allocation_, stub4.allocation_);
+ EXPECT_EQ(stub5.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_GT(stub6.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub7.allocation_.gpu_resource_size_in_bytes, 1ul);
}
// Test GpuMemoryManager::Manage functionality: Test changing importance of
@@ -406,10 +415,10 @@ TEST_F(GpuMemoryManagerTest, TestManageChangingImportanceShareGroup) {
EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, true);
EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, true);
- EXPECT_EQ(stub3.allocation_, stub1.allocation_);
- EXPECT_EQ(stub3.allocation_, stub2.allocation_);
- EXPECT_EQ(stub4.allocation_, stub1.allocation_);
- EXPECT_EQ(stub4.allocation_, stub2.allocation_);
+ EXPECT_GT(stub1.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub2.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
stub1.surface_state_.visible = false;
@@ -418,10 +427,10 @@ TEST_F(GpuMemoryManagerTest, TestManageChangingImportanceShareGroup) {
EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false);
EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, true);
- EXPECT_NE(stub3.allocation_, stub1.allocation_);
- EXPECT_EQ(stub3.allocation_, stub2.allocation_);
- EXPECT_NE(stub4.allocation_, stub1.allocation_);
- EXPECT_EQ(stub4.allocation_, stub2.allocation_);
+ EXPECT_EQ(stub1.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_GT(stub2.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
stub2.surface_state_.visible = false;
@@ -430,10 +439,10 @@ TEST_F(GpuMemoryManagerTest, TestManageChangingImportanceShareGroup) {
EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false);
EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false);
- EXPECT_EQ(stub3.allocation_, stub1.allocation_);
- EXPECT_EQ(stub3.allocation_, stub2.allocation_);
- EXPECT_EQ(stub4.allocation_, stub1.allocation_);
- EXPECT_EQ(stub4.allocation_, stub2.allocation_);
+ EXPECT_EQ(stub1.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_EQ(stub2.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_GT(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
stub1.surface_state_.last_used_time = older_;
@@ -442,10 +451,10 @@ TEST_F(GpuMemoryManagerTest, TestManageChangingImportanceShareGroup) {
EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false);
EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false);
- EXPECT_NE(stub3.allocation_, stub1.allocation_);
- EXPECT_EQ(stub3.allocation_, stub2.allocation_);
- EXPECT_NE(stub4.allocation_, stub1.allocation_);
- EXPECT_EQ(stub4.allocation_, stub2.allocation_);
+ EXPECT_EQ(stub1.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_EQ(stub2.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_GT(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
+ EXPECT_GT(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
stub2.surface_state_.last_used_time = older_;
@@ -454,10 +463,10 @@ TEST_F(GpuMemoryManagerTest, TestManageChangingImportanceShareGroup) {
EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false);
EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, false);
EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false);
- EXPECT_EQ(stub3.allocation_, stub1.allocation_);
- EXPECT_EQ(stub3.allocation_, stub2.allocation_);
- EXPECT_EQ(stub4.allocation_, stub1.allocation_);
- EXPECT_EQ(stub4.allocation_, stub2.allocation_);
+ EXPECT_EQ(stub1.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_EQ(stub2.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_EQ(stub3.allocation_.gpu_resource_size_in_bytes, 0ul);
+ EXPECT_EQ(stub4.allocation_.gpu_resource_size_in_bytes, 0ul);
}
// Test GpuMemoryAllocation comparison operators: Iterate over all possible

Powered by Google App Engine
This is Rietveld 408576698