content/common/gpu/gpu_memory_manager_unittest.cc
// 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 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 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 stubIgnoreA(memmgr_, GenerateUniqueSurfaceId(), true, newer_),
             stubIgnoreB(memmgr_, GenerateUniqueSurfaceId(), false, newer_),
             stubIgnoreC(memmgr_, GenerateUniqueSurfaceId(), false, newer_);
  FakeClient stub1(memmgr_, GenerateUniqueSurfaceId(), true, newest_),
             stub2(memmgr_, GenerateUniqueSurfaceId(), true, newest_);
  FakeClient stub3(memmgr_), stub4(memmgr_);
  stub3.SetInSameShareGroup(&stub2);
  stub4.SetInSameShareGroup(&stub2);
  Manage();
  EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub1.allocation_));
  EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub2.allocation_));
  EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub3.allocation_));
  EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub4.allocation_));
  memmgr_.TestingSetClientVisible(&stub1, false);
  Manage();
  EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub1.allocation_));
  EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub2.allocation_));
  EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub3.allocation_));
  EXPECT_TRUE(IsAllocationForegroundForSurfaceNo(stub4.allocation_));
  memmgr_.TestingSetClientVisible(&stub2, false);
  Manage();
  EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub1.allocation_));
  EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub2.allocation_));
  EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub3.allocation_));
  EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub4.allocation_));
  memmgr_.TestingSetClientLastUsedTime(&stub1, older_);
  Manage();
  EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub1.allocation_));
  EXPECT_TRUE(IsAllocationBackgroundForSurfaceYes(stub2.allocation_));
  EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub3.allocation_));
  EXPECT_TRUE(IsAllocationBackgroundForSurfaceNo(stub4.allocation_));
  memmgr_.TestingSetClientLastUsedTime(&stub2, older_);
  Manage();
  EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub1.allocation_));
  EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub2.allocation_));
  EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub3.allocation_));
  EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub4.allocation_));
}
TEST_F ( GpuMemoryManagerTest , TestManageChangingImportanceShareGroup ) { FakeClient stubIgnoreA ( memmgr_ , GenerateUniqueSurfaceId ( ) , true , newer_ ) , stubIgnoreB ( memmgr_ , GenerateUniqueSurfaceId ( ) , false , newer_ ) , stubIgnoreC ( memmgr_ , GenerateUniqueSurfaceId ( ) , false , newer_ ) ; FakeClient stub1 ( memmgr_ , GenerateUniqueSurfaceId ( ) , true , newest_ ) , stub2 ( memmgr_ , GenerateUniqueSurfaceId ( ) , true , newest_ ) ; FakeClient stub3 ( memmgr_ ) , stub4 ( memmgr_ ) ; stub3 . SetInSameShareGroup ( & stub2 ) ; stub4 . SetInSameShareGroup ( & stub2 ) ; Manage ( ) ; EXPECT_TRUE ( IsAllocationForegroundForSurfaceYes ( stub1 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationForegroundForSurfaceYes ( stub2 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationForegroundForSurfaceNo ( stub3 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationForegroundForSurfaceNo ( stub4 . allocation_ ) ) ; memmgr_ . TestingSetClientVisible ( & stub1 , false ) ; Manage ( ) ; EXPECT_TRUE ( IsAllocationBackgroundForSurfaceYes ( stub1 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationForegroundForSurfaceYes ( stub2 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationBackgroundForSurfaceNo ( stub3 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationForegroundForSurfaceNo ( stub4 . allocation_ ) ) ; memmgr_ . TestingSetClientVisible ( & stub2 , false ) ; Manage ( ) ; EXPECT_TRUE ( IsAllocationBackgroundForSurfaceYes ( stub1 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationBackgroundForSurfaceYes ( stub2 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationBackgroundForSurfaceNo ( stub3 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationBackgroundForSurfaceNo ( stub4 . allocation_ ) ) ; memmgr_ . TestingSetClientLastUsedTime ( & stub1 , older_ ) ; Manage ( ) ; EXPECT_TRUE ( IsAllocationHibernatedForSurfaceYes ( stub1 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationBackgroundForSurfaceYes ( stub2 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationBackgroundForSurfaceNo ( stub3 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationBackgroundForSurfaceNo ( stub4 . allocation_ ) ) ; memmgr_ . TestingSetClientLastUsedTime ( & stub2 , older_ ) ; Manage ( ) ; EXPECT_TRUE ( IsAllocationHibernatedForSurfaceYes ( stub1 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationHibernatedForSurfaceYes ( stub2 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationHibernatedForSurfaceNo ( stub3 . allocation_ ) ) ; EXPECT_TRUE ( IsAllocationHibernatedForSurfaceNo ( stub4 . allocation_ ) ) ; }
Test GpuMemoryManager::Manage functionality: Test changing importance of
enough stubs so that every stub in share group crosses threshold.
Test GpuMemoryManager :: Manage functionality : Test changing importance of enough stubs so that every stub in share group crosses threshold .