src/ui/scenic/lib/flatland/tests/flatland_unittest.cc
// Test that released Images, when attached to a Transform, are not garbage collected even if
// the Transform is not part of the most recently presented global topology.
Test that released Images, when attached to a Transform, are not garbage collected even if
the Transform is not part of the most recently presented global topology.
Test that released Images when attached to a Transform are not garbage collected even if the Transform is not part of the most recently presented global topology .
TEST_F(FlatlandTest, ReleasedImagePersistsOutsideGlobalTopology) {
  Flatland flatland = CreateFlatland();
  const ContentId kImageId = 1;
  const BufferCollectionId kBufferCollectionId = 1;
  ImageProperties properties1;
  properties1.set_width(100);
  properties1.set_height(200);
  const GlobalBufferCollectionId global_collection_id1 =
      CreateImage(&flatland, kImageId, kBufferCollectionId, std::move(properties1));
  const TransformId kTransformId = 2;
  flatland.CreateTransform(kTransformId);
  flatland.SetRootTransform(kTransformId);
  flatland.SetContentOnTransform(kImageId, kTransformId);
  flatland.ReleaseImage(kImageId);
  PRESENT(flatland, true);
  flatland.SetRootTransform(0);
  PRESENT(flatland, true);
  auto data = ProcessMainLoop(flatland.GetRoot());
  EXPECT_EQ(data.image_vector.size(), 0ul);
  flatland.SetRootTransform(kTransformId);
  PRESENT(flatland, true);
  data = ProcessMainLoop(flatland.GetRoot());
  EXPECT_EQ(data.image_vector.size(), 1ul);
  EXPECT_EQ(data.image_vector[0].collection_id, global_collection_id1);
}
TEST_F ( FlatlandTest , ReleasedImagePersistsOutsideGlobalTopology ) { Flatland flatland = CreateFlatland ( ) ; const ContentId kImageId = 1 ; const BufferCollectionId kBufferCollectionId = 1 ; ImageProperties properties1 ; properties1 . set_width ( 100 ) ; properties1 . set_height ( 200 ) ; const GlobalBufferCollectionId global_collection_id1 = CreateImage ( & flatland , kImageId , kBufferCollectionId , std :: move ( properties1 ) ) ; const TransformId kTransformId = 2 ; flatland . CreateTransform ( kTransformId ) ; flatland . SetRootTransform ( kTransformId ) ; flatland . SetContentOnTransform ( kImageId , kTransformId ) ; flatland . ReleaseImage ( kImageId ) ; PRESENT ( flatland , true ) ; flatland . SetRootTransform ( 0 ) ; PRESENT ( flatland , true ) ; auto data = ProcessMainLoop ( flatland . GetRoot ( ) ) ; EXPECT_EQ ( data . image_vector . size ( ) , 0ul ) ; flatland . SetRootTransform ( kTransformId ) ; PRESENT ( flatland , true ) ; data = ProcessMainLoop ( flatland . GetRoot ( ) ) ; EXPECT_EQ ( data . image_vector . size ( ) , 1ul ) ; EXPECT_EQ ( data . image_vector [ 0 ] . collection_id , global_collection_id1 ) ; }
Test that released Images, when attached to a Transform, are not garbage collected even if
the Transform is not part of the most recently presented global topology.
Test that released Images when attached to a Transform are not garbage collected even if the Transform is not part of the most recently presented global topology .
// Setup a valid image. // Create a transform, make it the root transform, attach the image, then release it. // Remove the entire hierarchy, then verify that no images are present. // Reintroduce the hierarchy and confirm the Image is still present, even though it was // temporarily not reachable from the root transform.