lullaby/tests/sort_order_test.cc
// Tests that the sort orders of an entire hierarchy with explicit offsets are
// calculated as expected.
Tests that the sort orders of an entire hierarchy with explicit offsets are
calculated as expected.
Tests that the sort orders of an entire hierarchy with explicit offsets are calculated as expected .
TEST(SortOrderTest, SimpleHierarchyOrder) {
  Registry registry;
  SortOrderManager manager(&registry);
  auto* transform_system = CreateTransformSystemWithEntities(&registry, 8);
   hierarchy   | offsets
     1         |   1
   2    3      | 1   -1
      4    5   |    1    2
         6 7 8 |       3 4 -5
  transform_system->AddChild(1, 2);
  transform_system->AddChild(1, 3);
  transform_system->AddChild(3, 4);
  transform_system->AddChild(3, 5);
  transform_system->AddChild(5, 6);
  transform_system->AddChild(5, 7);
  transform_system->AddChild(5, 8);
  manager.SetOffset(Entity(1), 1);
  manager.SetOffset(Entity(2), 1);
  manager.SetOffset(Entity(3), -1);
  manager.SetOffset(Entity(4), 1);
  manager.SetOffset(Entity(5), 2);
  manager.SetOffset(Entity(6), 3);
  manager.SetOffset(Entity(7), 4);
  manager.SetOffset(Entity(8), -5);
  EXPECT_THAT(manager.CalculateSortOrder(Entity(1)).ToHexString(),
              Eq("0x10000000000000000000000000000000"));
  EXPECT_THAT(manager.CalculateSortOrder(Entity(2)).ToHexString(),
              Eq("0x11000000000000000000000000000000"));
  EXPECT_THAT(manager.CalculateSortOrder(Entity(3)).ToHexString(),
              Eq("0x0F000000000000000000000000000000"));
  EXPECT_THAT(manager.CalculateSortOrder(Entity(4)).ToHexString(),
              Eq("0x0F100000000000000000000000000000"));
  EXPECT_THAT(manager.CalculateSortOrder(Entity(5)).ToHexString(),
              Eq("0x0F200000000000000000000000000000"));
  EXPECT_THAT(manager.CalculateSortOrder(Entity(6)).ToHexString(),
              Eq("0x0F230000000000000000000000000000"));
  EXPECT_THAT(manager.CalculateSortOrder(Entity(7)).ToHexString(),
              Eq("0x0F240000000000000000000000000000"));
  EXPECT_THAT(manager.CalculateSortOrder(Entity(8)).ToHexString(),
              Eq("0x0F1B0000000000000000000000000000"));
}
TEST ( SortOrderTest , SimpleHierarchyOrder ) { Registry registry ; SortOrderManager manager ( & registry ) ; auto * transform_system = CreateTransformSystemWithEntities ( & registry , 8 ) ; transform_system -> AddChild ( 1 , 2 ) ; transform_system -> AddChild ( 1 , 3 ) ; transform_system -> AddChild ( 3 , 4 ) ; transform_system -> AddChild ( 3 , 5 ) ; transform_system -> AddChild ( 5 , 6 ) ; transform_system -> AddChild ( 5 , 7 ) ; transform_system -> AddChild ( 5 , 8 ) ; manager . SetOffset ( Entity ( 1 ) , 1 ) ; manager . SetOffset ( Entity ( 2 ) , 1 ) ; manager . SetOffset ( Entity ( 3 ) , -1 ) ; manager . SetOffset ( Entity ( 4 ) , 1 ) ; manager . SetOffset ( Entity ( 5 ) , 2 ) ; manager . SetOffset ( Entity ( 6 ) , 3 ) ; manager . SetOffset ( Entity ( 7 ) , 4 ) ; manager . SetOffset ( Entity ( 8 ) , -5 ) ; EXPECT_THAT ( manager . CalculateSortOrder ( Entity ( 1 ) ) . ToHexString ( ) , Eq ( " " ) ) ; EXPECT_THAT ( manager . CalculateSortOrder ( Entity ( 2 ) ) . ToHexString ( ) , Eq ( " " ) ) ; EXPECT_THAT ( manager . CalculateSortOrder ( Entity ( 3 ) ) . ToHexString ( ) , Eq ( " " ) ) ; EXPECT_THAT ( manager . CalculateSortOrder ( Entity ( 4 ) ) . ToHexString ( ) , Eq ( " " ) ) ; EXPECT_THAT ( manager . CalculateSortOrder ( Entity ( 5 ) ) . ToHexString ( ) , Eq ( " " ) ) ; EXPECT_THAT ( manager . CalculateSortOrder ( Entity ( 6 ) ) . ToHexString ( ) , Eq ( " " ) ) ; EXPECT_THAT ( manager . CalculateSortOrder ( Entity ( 7 ) ) . ToHexString ( ) , Eq ( " " ) ) ; EXPECT_THAT ( manager . CalculateSortOrder ( Entity ( 8 ) ) . ToHexString ( ) , Eq ( " " ) ) ; }
Tests that the sort orders of an entire hierarchy with explicit offsets are
calculated as expected.
Tests that the sort orders of an entire hierarchy with explicit offsets are calculated as expected .
// Create a hierarchy (with offsets) like so: // // hierarchy   | offsets //   1         |   1 // 2    3      | 1   -1 //    4    5   |    1    2 //       6 7 8 |       3 4 -5