content/common/gpu/gpu_memory_manager_unittest.cc
// Test GpuMemoryManager Stub Memory Stats functionality:
// Creats various surface/non-surface stubs and switches stub visibility and
// tests to see that stats data structure values are correct.
Test GpuMemoryManager Stub Memory Stats functionality:
Creats various surface/non-surface stubs and switches stub visibility and
tests to see that stats data structure values are correct.
Test GpuMemoryManager Stub Memory Stats functionality : Creats various surface / non - surface stubs and switches stub visibility and tests to see that stats data structure values are correct .
TEST_F(GpuMemoryManagerTest, StubMemoryStatsForLastManageTests) {
  ClientAssignmentCollector::ClientMemoryStatMap stats;
  Manage();
  stats = ClientAssignmentCollector::GetClientStatsForLastManage();
  EXPECT_EQ(stats.size(), 0ul);
  FakeClient stub1(memmgr_, GenerateUniqueSurfaceId(), true, older_);
  Manage();
  stats = ClientAssignmentCollector::GetClientStatsForLastManage();
  size_t stub1allocation1 =
      stats[&stub1].allocation.renderer_allocation.bytes_limit_when_visible;
  EXPECT_EQ(stats.size(), 1ul);
  EXPECT_GT(stub1allocation1, 0ul);
  FakeClient stub2(memmgr_);
  stub2.SetInSameShareGroup(&stub1);
  Manage();
  stats = ClientAssignmentCollector::GetClientStatsForLastManage();
  EXPECT_EQ(stats.count(&stub1), 1ul);
  size_t stub1allocation2 =
      stats[&stub1].allocation.renderer_allocation.bytes_limit_when_visible;
  EXPECT_EQ(stats.count(&stub2), 1ul);
  size_t stub2allocation2 =
      stats[&stub2].allocation.renderer_allocation.bytes_limit_when_visible;
  EXPECT_EQ(stats.size(), 2ul);
  EXPECT_GT(stub1allocation2, 0ul);
  EXPECT_GT(stub2allocation2, 0ul);
  if (stub1allocation2 != GetMaximumTabAllocation())
    EXPECT_LT(stub1allocation2, stub1allocation1);
  FakeClient stub3(memmgr_, GenerateUniqueSurfaceId(), true, older_);
  Manage();
  stats = ClientAssignmentCollector::GetClientStatsForLastManage();
  size_t stub1allocation3 =
      stats[&stub1].allocation.renderer_allocation.bytes_limit_when_visible;
  size_t stub2allocation3 =
      stats[&stub2].allocation.renderer_allocation.bytes_limit_when_visible;
  size_t stub3allocation3 =
      stats[&stub3].allocation.renderer_allocation.bytes_limit_when_visible;
  EXPECT_EQ(stats.size(), 3ul);
  EXPECT_GT(stub1allocation3, 0ul);
  EXPECT_GT(stub2allocation3, 0ul);
  EXPECT_GT(stub3allocation3, 0ul);
  if (stub1allocation3 != GetMaximumTabAllocation())
    EXPECT_LT(stub1allocation3, stub1allocation2);
  memmgr_.TestingSetClientVisible(&stub1, false);
  Manage();
  stats = ClientAssignmentCollector::GetClientStatsForLastManage();
  size_t stub1allocation4 =
      stats[&stub1].allocation.renderer_allocation.bytes_limit_when_visible;
  size_t stub2allocation4 =
      stats[&stub2].allocation.renderer_allocation.bytes_limit_when_visible;
  size_t stub3allocation4 =
      stats[&stub3].allocation.renderer_allocation.bytes_limit_when_visible;
  EXPECT_EQ(stats.size(), 3ul);
  EXPECT_GT(stub1allocation4, 0ul);
  EXPECT_GE(stub2allocation4, 0ul);
  EXPECT_GT(stub3allocation4, 0ul);
  if (stub3allocation3 != GetMaximumTabAllocation())
    EXPECT_GT(stub3allocation4, stub3allocation3);
}
TEST_F ( GpuMemoryManagerTest , StubMemoryStatsForLastManageTests ) { ClientAssignmentCollector :: ClientMemoryStatMap stats ; Manage ( ) ; stats = ClientAssignmentCollector :: GetClientStatsForLastManage ( ) ; EXPECT_EQ ( stats . size ( ) , 0ul ) ; FakeClient stub1 ( memmgr_ , GenerateUniqueSurfaceId ( ) , true , older_ ) ; Manage ( ) ; stats = ClientAssignmentCollector :: GetClientStatsForLastManage ( ) ; size_t stub1allocation1 = stats [ & stub1 ] . allocation . renderer_allocation . bytes_limit_when_visible ; EXPECT_EQ ( stats . size ( ) , 1ul ) ; EXPECT_GT ( stub1allocation1 , 0ul ) ; FakeClient stub2 ( memmgr_ ) ; stub2 . SetInSameShareGroup ( & stub1 ) ; Manage ( ) ; stats = ClientAssignmentCollector :: GetClientStatsForLastManage ( ) ; EXPECT_EQ ( stats . count ( & stub1 ) , 1ul ) ; size_t stub1allocation2 = stats [ & stub1 ] . allocation . renderer_allocation . bytes_limit_when_visible ; EXPECT_EQ ( stats . count ( & stub2 ) , 1ul ) ; size_t stub2allocation2 = stats [ & stub2 ] . allocation . renderer_allocation . bytes_limit_when_visible ; EXPECT_EQ ( stats . size ( ) , 2ul ) ; EXPECT_GT ( stub1allocation2 , 0ul ) ; EXPECT_GT ( stub2allocation2 , 0ul ) ; if ( stub1allocation2 != GetMaximumTabAllocation ( ) ) EXPECT_LT ( stub1allocation2 , stub1allocation1 ) ; FakeClient stub3 ( memmgr_ , GenerateUniqueSurfaceId ( ) , true , older_ ) ; Manage ( ) ; stats = ClientAssignmentCollector :: GetClientStatsForLastManage ( ) ; size_t stub1allocation3 = stats [ & stub1 ] . allocation . renderer_allocation . bytes_limit_when_visible ; size_t stub2allocation3 = stats [ & stub2 ] . allocation . renderer_allocation . bytes_limit_when_visible ; size_t stub3allocation3 = stats [ & stub3 ] . allocation . renderer_allocation . bytes_limit_when_visible ; EXPECT_EQ ( stats . size ( ) , 3ul ) ; EXPECT_GT ( stub1allocation3 , 0ul ) ; EXPECT_GT ( stub2allocation3 , 0ul ) ; EXPECT_GT ( stub3allocation3 , 0ul ) ; if ( stub1allocation3 != GetMaximumTabAllocation ( ) ) EXPECT_LT ( stub1allocation3 , stub1allocation2 ) ; memmgr_ . TestingSetClientVisible ( & stub1 , false ) ; Manage ( ) ; stats = ClientAssignmentCollector :: GetClientStatsForLastManage ( ) ; size_t stub1allocation4 = stats [ & stub1 ] . allocation . renderer_allocation . bytes_limit_when_visible ; size_t stub2allocation4 = stats [ & stub2 ] . allocation . renderer_allocation . bytes_limit_when_visible ; size_t stub3allocation4 = stats [ & stub3 ] . allocation . renderer_allocation . bytes_limit_when_visible ; EXPECT_EQ ( stats . size ( ) , 3ul ) ; EXPECT_GT ( stub1allocation4 , 0ul ) ; EXPECT_GE ( stub2allocation4 , 0ul ) ; EXPECT_GT ( stub3allocation4 , 0ul ) ; if ( stub3allocation3 != GetMaximumTabAllocation ( ) ) EXPECT_GT ( stub3allocation4 , stub3allocation3 ) ; }
Test GpuMemoryManager Stub Memory Stats functionality:
Creats various surface/non-surface stubs and switches stub visibility and
tests to see that stats data structure values are correct.
Test GpuMemoryManager Stub Memory Stats functionality : Creats various surface / non - surface stubs and switches stub visibility and tests to see that stats data structure values are correct .