lullaby/tests/sort_order_test.cc
// Tests that a subtree is updated by a call to UpdateSortOrder.
Tests that a subtree is updated by a call to UpdateSortOrder.
Tests that a subtree is updated by a call to UpdateSortOrder .
TEST(SortOrderTest, UpdateSortOrder) {
  Registry registry;
  SortOrderManager manager(&registry);
  RenderPoolMap<TestComponent> component_map(&registry);
  const int kNumHierarchyEntities = 4;
  const int kNumEntities = kNumHierarchyEntities + 1;
  auto* transform_system = CreateTransformSystemWithEntities(
      &registry, kNumEntities, &component_map);
  for (int i = 1; i <= kNumEntities; ++i) {
    EXPECT_THAT(component_map.GetComponent(i)->sort_order,
                Eq(kDefaultSortOrder));
  }
  for (int i = 1; i < kNumHierarchyEntities; ++i) {
    transform_system->AddChild(i, i + 1);
  }
  manager.UpdateSortOrder(Entity(2), [&](detail::EntityIdPair entity_id_pair) {
    return component_map.GetComponent(entity_id_pair.entity);
  });
  EXPECT_THAT(component_map.GetComponent(2)->sort_order.ToHexString(),
              Eq("0x11000000000000000000000000000000"));
  EXPECT_THAT(component_map.GetComponent(3)->sort_order.ToHexString(),
              Eq("0x11100000000000000000000000000000"));
  EXPECT_THAT(component_map.GetComponent(4)->sort_order.ToHexString(),
              Eq("0x11110000000000000000000000000000"));
  EXPECT_THAT(component_map.GetComponent(1)->sort_order, Eq(kDefaultSortOrder));
  EXPECT_THAT(component_map.GetComponent(5)->sort_order, Eq(kDefaultSortOrder));
}
TEST ( SortOrderTest , UpdateSortOrder ) { Registry registry ; SortOrderManager manager ( & registry ) ; RenderPoolMap < TestComponent > component_map ( & registry ) ; const int kNumHierarchyEntities = 4 ; const int kNumEntities = kNumHierarchyEntities + 1 ; auto * transform_system = CreateTransformSystemWithEntities ( & registry , kNumEntities , & component_map ) ; for ( int i = 1 ; i <= kNumEntities ; ++ i ) { EXPECT_THAT ( component_map . GetComponent ( i ) -> sort_order , Eq ( kDefaultSortOrder ) ) ; } for ( int i = 1 ; i < kNumHierarchyEntities ; ++ i ) { transform_system -> AddChild ( i , i + 1 ) ; } manager . UpdateSortOrder ( Entity ( 2 ) , [ & ] ( detail :: EntityIdPair entity_id_pair ) { return component_map . GetComponent ( entity_id_pair . entity ) ; } ) ; EXPECT_THAT ( component_map . GetComponent ( 2 ) -> sort_order . ToHexString ( ) , Eq ( " " ) ) ; EXPECT_THAT ( component_map . GetComponent ( 3 ) -> sort_order . ToHexString ( ) , Eq ( " " ) ) ; EXPECT_THAT ( component_map . GetComponent ( 4 ) -> sort_order . ToHexString ( ) , Eq ( " " ) ) ; EXPECT_THAT ( component_map . GetComponent ( 1 ) -> sort_order , Eq ( kDefaultSortOrder ) ) ; EXPECT_THAT ( component_map . GetComponent ( 5 ) -> sort_order , Eq ( kDefaultSortOrder ) ) ; }
Tests that a subtree is updated by a call to UpdateSortOrder.
Tests that a subtree is updated by a call to UpdateSortOrder .
// Leave one entity outside the hierarchy completely. // Make sure all sort orders start at kDefaultSortOrder. // Create the hierarchy. // Update only a subtree of the hierarchy. // Make sure that the sort orders for the subtree were updated. // Check that the entities outside the subtree weren't updated.