content/common/gpu/gpu_memory_manager_unittest.cc
// Test GpuMemoryAllocation memory allocation bonuses:
// When the number of visible tabs is small, each tab should get a
// gpu_resource_size_in_bytes allocation value that is greater than
// GetMinimumTabAllocation(), and when the number of tabs is large, each should
// get exactly GetMinimumTabAllocation() and not less.
Test GpuMemoryAllocation memory allocation bonuses:
When the number of visible tabs is small, each tab should get a
gpu_resource_size_in_bytes allocation value that is greater than
GetMinimumTabAllocation(), and when the number of tabs is large, each should
get exactly GetMinimumTabAllocation() and not less.
Test GpuMemoryAllocation memory allocation bonuses : When the number of visible tabs is small each tab should get a gpu_resource_size_in_bytes allocation value that is greater than GetMinimumTabAllocation () and when the number of tabs is large each should get exactly GetMinimumTabAllocation () and not less .
TEST_F(GpuMemoryManagerTest, TestForegroundStubsGetBonusAllocation) {
  size_t max_stubs_before_no_bonus =
      GetAvailableGpuMemory() / (GetMinimumTabAllocation() + 1);
  std::vector<FakeClient*> stubs;
  for (size_t i = 0; i < max_stubs_before_no_bonus; ++i) {
    stubs.push_back(
        new FakeClient(memmgr_, GenerateUniqueSurfaceId(), true, older_));
  }
  Manage();
  for (size_t i = 0; i < stubs.size(); ++i) {
    EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stubs[i]->allocation_));
    EXPECT_GT(
        stubs[i]->allocation_.renderer_allocation.bytes_limit_when_visible,
        static_cast<size_t>(GetMinimumTabAllocation()));
  }
  FakeClient extra_stub(memmgr_, GenerateUniqueSurfaceId(), true, older_);
  Manage();
  for (size_t i = 0; i < stubs.size(); ++i) {
    EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stubs[i]->allocation_));
    EXPECT_EQ(
        stubs[i]->allocation_.renderer_allocation.bytes_limit_when_visible,
        GetMinimumTabAllocation());
  }
  for (size_t i = 0; i < max_stubs_before_no_bonus; ++i) {
    delete stubs[i];
  }
}
TEST_F ( GpuMemoryManagerTest , TestForegroundStubsGetBonusAllocation ) { size_t max_stubs_before_no_bonus = GetAvailableGpuMemory ( ) / ( GetMinimumTabAllocation ( ) + 1 ) ; std :: vector < FakeClient * > stubs ; for ( size_t i = 0 ; i < max_stubs_before_no_bonus ; ++ i ) { stubs . push_back ( new FakeClient ( memmgr_ , GenerateUniqueSurfaceId ( ) , true , older_ ) ) ; } Manage ( ) ; for ( size_t i = 0 ; i < stubs . size ( ) ; ++ i ) { EXPECT_TRUE ( IsAllocationForegroundForSurfaceYes ( stubs [ i ] -> allocation_ ) ) ; EXPECT_GT ( stubs [ i ] -> allocation_ . renderer_allocation . bytes_limit_when_visible , static_cast < size_t > ( GetMinimumTabAllocation ( ) ) ) ; } FakeClient extra_stub ( memmgr_ , GenerateUniqueSurfaceId ( ) , true , older_ ) ; Manage ( ) ; for ( size_t i = 0 ; i < stubs . size ( ) ; ++ i ) { EXPECT_TRUE ( IsAllocationForegroundForSurfaceYes ( stubs [ i ] -> allocation_ ) ) ; EXPECT_EQ ( stubs [ i ] -> allocation_ . renderer_allocation . bytes_limit_when_visible , GetMinimumTabAllocation ( ) ) ; } for ( size_t i = 0 ; i < max_stubs_before_no_bonus ; ++ i ) { delete stubs [ i ] ; } }
Test GpuMemoryAllocation memory allocation bonuses:
When the number of visible tabs is small, each tab should get a
gpu_resource_size_in_bytes allocation value that is greater than
GetMinimumTabAllocation(), and when the number of tabs is large, each should
get exactly GetMinimumTabAllocation() and not less.
Test GpuMemoryAllocation memory allocation bonuses : When the number of visible tabs is small each tab should get a gpu_resource_size_in_bytes allocation value that is greater than GetMinimumTabAllocation () and when the number of tabs is large each should get exactly GetMinimumTabAllocation () and not less .