content/common/gpu/gpu_memory_manager_unittest.cc
// Test GpuMemoryManager's background cutoff threshoulds
Test GpuMemoryManager's background cutoff threshoulds
Test GpuMemoryManager ' s background cutoff threshoulds
TEST_F(GpuMemoryManagerTest, TestBackgroundCutoff) {
  memmgr_.TestingSetAvailableGpuMemory(64);
  memmgr_.TestingSetBackgroundedAvailableGpuMemory(16);
  FakeClient stub1(memmgr_, GenerateUniqueSurfaceId(), true, older_);
  stub1.SetUsageStats(16, 24, 18);
  Manage();
  EXPECT_EQ(0ul, stub1.BytesWhenNotVisible());
  stub1.SetUsageStats(15, 24, 18);
  Manage();
  EXPECT_EQ(memmgr_.bytes_backgrounded_available_gpu_memory_,
            memmgr_.GetCurrentBackgroundedAvailableGpuMemory());
  EXPECT_EQ(memmgr_.GetCurrentBackgroundedAvailableGpuMemory(),
            stub1.BytesWhenNotVisible());
  stub1.SetUsageStats(15, 24, 15);
  stub1.SetVisible(false);
  FakeClient stub2(memmgr_, GenerateUniqueSurfaceId(), true, older_);
  stub2.SetUsageStats(15, 50, 48);
  Manage();
  EXPECT_EQ(memmgr_.bytes_backgrounded_available_gpu_memory_,
            memmgr_.GetCurrentBackgroundedAvailableGpuMemory());
  EXPECT_EQ(memmgr_.GetCurrentBackgroundedAvailableGpuMemory(),
            stub1.BytesWhenNotVisible());
  EXPECT_EQ(memmgr_.GetCurrentBackgroundedAvailableGpuMemory(),
            stub2.BytesWhenNotVisible());
  stub2.SetUsageStats(15, 50, 49);
  Manage();
  EXPECT_EQ(0ul,
            stub1.BytesWhenNotVisible());
  EXPECT_EQ(memmgr_.GetCurrentBackgroundedAvailableGpuMemory(),
            stub2.BytesWhenNotVisible());
}
TEST_F ( GpuMemoryManagerTest , TestBackgroundCutoff ) { memmgr_ . TestingSetAvailableGpuMemory ( 64 ) ; memmgr_ . TestingSetBackgroundedAvailableGpuMemory ( 16 ) ; FakeClient stub1 ( memmgr_ , GenerateUniqueSurfaceId ( ) , true , older_ ) ; stub1 . SetUsageStats ( 16 , 24 , 18 ) ; Manage ( ) ; EXPECT_EQ ( 0ul , stub1 . BytesWhenNotVisible ( ) ) ; stub1 . SetUsageStats ( 15 , 24 , 18 ) ; Manage ( ) ; EXPECT_EQ ( memmgr_ . bytes_backgrounded_available_gpu_memory_ , memmgr_ . GetCurrentBackgroundedAvailableGpuMemory ( ) ) ; EXPECT_EQ ( memmgr_ . GetCurrentBackgroundedAvailableGpuMemory ( ) , stub1 . BytesWhenNotVisible ( ) ) ; stub1 . SetUsageStats ( 15 , 24 , 15 ) ; stub1 . SetVisible ( false ) ; FakeClient stub2 ( memmgr_ , GenerateUniqueSurfaceId ( ) , true , older_ ) ; stub2 . SetUsageStats ( 15 , 50 , 48 ) ; Manage ( ) ; EXPECT_EQ ( memmgr_ . bytes_backgrounded_available_gpu_memory_ , memmgr_ . GetCurrentBackgroundedAvailableGpuMemory ( ) ) ; EXPECT_EQ ( memmgr_ . GetCurrentBackgroundedAvailableGpuMemory ( ) , stub1 . BytesWhenNotVisible ( ) ) ; EXPECT_EQ ( memmgr_ . GetCurrentBackgroundedAvailableGpuMemory ( ) , stub2 . BytesWhenNotVisible ( ) ) ; stub2 . SetUsageStats ( 15 , 50 , 49 ) ; Manage ( ) ; EXPECT_EQ ( 0ul , stub1 . BytesWhenNotVisible ( ) ) ; EXPECT_EQ ( memmgr_ . GetCurrentBackgroundedAvailableGpuMemory ( ) , stub2 . BytesWhenNotVisible ( ) ) ; }
Test GpuMemoryManager's background cutoff threshoulds
Test GpuMemoryManager ' s background cutoff threshoulds
// stub1's requirements are not <16, so it should just dump // everything when it goes invisible. // stub1 now fits, so it should have a full budget. // background stub1 // Add stub2 that uses almost enough memory to evict // stub1, but not quite // Increase stub2 to break evict stub1