src/ui/scenic/lib/flatland/tests/flatland_unittest.cc
// Tests that a buffer collection is not deregistered from the Renderer until it is not referenced
// by any active Image (including released Images still on Transforms) and the release fence is
// signaled.
Tests that a buffer collection is not deregistered from the Renderer until it is not referenced
by any active Image (including released Images still on Transforms) and the release fence is
signaled.
Tests that a buffer collection is not deregistered from the Renderer until it is not referenced by any active Image ( including released Images still on Transforms ) and the release fence is signaled .
TEST_F(FlatlandTest, DeregisterBufferCollectionWaitsForReleaseFence) {
  Flatland flatland = CreateFlatland();
  const ContentId kImageId = 1;
  const BufferCollectionId kBufferCollectionId = 2;
  ImageProperties properties;
  properties.set_width(100);
  properties.set_height(200);
  const GlobalBufferCollectionId global_collection_id =
      CreateImage(&flatland, kImageId, kBufferCollectionId, std::move(properties));
  const TransformId kTransformId = 3;
  flatland.CreateTransform(kTransformId);
  flatland.SetRootTransform(kTransformId);
  flatland.SetContentOnTransform(kImageId, kTransformId);
  PRESENT(flatland, true);
  EXPECT_CALL(*mock_renderer_, DeregisterCollection(global_collection_id)).Times(0);
  flatland.DeregisterBufferCollection(kBufferCollectionId);
  PRESENT(flatland, true);
  EXPECT_CALL(*mock_renderer_, DeregisterCollection(global_collection_id)).Times(0);
  flatland.ReleaseImage(kImageId);
  PRESENT(flatland, true);
  EXPECT_CALL(*mock_renderer_, DeregisterCollection(global_collection_id)).Times(0);
  flatland.SetContentOnTransform(0, kTransformId);
  PRESENT(flatland, true);
  EXPECT_CALL(*mock_renderer_, DeregisterCollection(global_collection_id)).Times(1);
  flatland.SignalBufferReleaseFence();
  RunLoopUntilIdle();
}
TEST_F ( FlatlandTest , DeregisterBufferCollectionWaitsForReleaseFence ) { Flatland flatland = CreateFlatland ( ) ; const ContentId kImageId = 1 ; const BufferCollectionId kBufferCollectionId = 2 ; ImageProperties properties ; properties . set_width ( 100 ) ; properties . set_height ( 200 ) ; const GlobalBufferCollectionId global_collection_id = CreateImage ( & flatland , kImageId , kBufferCollectionId , std :: move ( properties ) ) ; const TransformId kTransformId = 3 ; flatland . CreateTransform ( kTransformId ) ; flatland . SetRootTransform ( kTransformId ) ; flatland . SetContentOnTransform ( kImageId , kTransformId ) ; PRESENT ( flatland , true ) ; EXPECT_CALL ( * mock_renderer_ , DeregisterCollection ( global_collection_id ) ) . Times ( 0 ) ; flatland . DeregisterBufferCollection ( kBufferCollectionId ) ; PRESENT ( flatland , true ) ; EXPECT_CALL ( * mock_renderer_ , DeregisterCollection ( global_collection_id ) ) . Times ( 0 ) ; flatland . ReleaseImage ( kImageId ) ; PRESENT ( flatland , true ) ; EXPECT_CALL ( * mock_renderer_ , DeregisterCollection ( global_collection_id ) ) . Times ( 0 ) ; flatland . SetContentOnTransform ( 0 , kTransformId ) ; PRESENT ( flatland , true ) ; EXPECT_CALL ( * mock_renderer_ , DeregisterCollection ( global_collection_id ) ) . Times ( 1 ) ; flatland . SignalBufferReleaseFence ( ) ; RunLoopUntilIdle ( ) ; }
Tests that a buffer collection is not deregistered from the Renderer until it is not referenced
by any active Image (including released Images still on Transforms) and the release fence is
signaled.
Tests that a buffer collection is not deregistered from the Renderer until it is not referenced by any active Image ( including released Images still on Transforms ) and the release fence is signaled .
// Setup a valid buffer collection and Image. // Attach the Image to a transform. // Deregister the buffer collection, but ensure that the deregistration call on the Renderer has // not happened. // Release the Image that referenced the buffer collection. Because the Image is still attached // to a Transform, the deregestration call should still not happen. // Remove the Image from the transform. This triggers the creation of the release fence, but // still does not result in a deregestration call. // Signal the release fences, which results in the deregistration call,