lullaby/tests/layout_system_test.cc
// Test that the LayoutSystem will use the previously set DesiredSize even in
// subsequent ActualBoxChangedEvents, supporting asynchronous mesh generators.
Test that the LayoutSystem will use the previously set DesiredSize even in
subsequent ActualBoxChangedEvents, supporting asynchronous mesh generators.
Test that the LayoutSystem will use the previously set DesiredSize even in subsequent ActualBoxChangedEvents supporting asynchronous mesh generators .
TEST_F(QueuedLayoutSystemTest, DesiredBox_Repeated) {
  const Entity parent = CreateParent();
  const Entity child = CreateChild(parent, 1.0f);
  dispatcher_->Dispatch();
  const Aabb* aabb = layout_box_system_->GetActualBox(parent);
  EXPECT_NEAR(-1.f, aabb->min.x, kEpsilon);
  EXPECT_NEAR(-1.f, aabb->min.y, kEpsilon);
  EXPECT_NEAR(1.f, aabb->max.x, kEpsilon);
  EXPECT_NEAR(1.f, aabb->max.y, kEpsilon);
  layout_box_system_->SetDesiredSize(parent, kNullEntity, 1.f, 1.f,
                                     Optional<float>());
  dispatcher_->Dispatch();
  aabb = layout_box_system_->GetActualBox(parent);
  EXPECT_NEAR(-0.5f, aabb->min.x, kEpsilon);
  EXPECT_NEAR(-0.5f, aabb->min.y, kEpsilon);
  EXPECT_NEAR(0.5f, aabb->max.x, kEpsilon);
  EXPECT_NEAR(0.5f, aabb->max.y, kEpsilon);
  layout_box_system_->SetActualBox(child, kNullEntity, Aabb({0.1f, 0.1f, 0.f},
                                                            {0.1f, 0.1f, 0.f}));
  dispatcher_->Dispatch();
  aabb = layout_box_system_->GetActualBox(parent);
  EXPECT_NEAR(-0.5f, aabb->min.x, kEpsilon);
  EXPECT_NEAR(-0.5f, aabb->min.y, kEpsilon);
  EXPECT_NEAR(0.5f, aabb->max.x, kEpsilon);
  EXPECT_NEAR(0.5f, aabb->max.y, kEpsilon);
}
TEST_F ( QueuedLayoutSystemTest , DesiredBox_Repeated ) { const Entity parent = CreateParent ( ) ; const Entity child = CreateChild ( parent , 1.0f ) ; dispatcher_ -> Dispatch ( ) ; const Aabb * aabb = layout_box_system_ -> GetActualBox ( parent ) ; EXPECT_NEAR ( -1.f , aabb -> min . x , kEpsilon ) ; EXPECT_NEAR ( -1.f , aabb -> min . y , kEpsilon ) ; EXPECT_NEAR ( 1.f , aabb -> max . x , kEpsilon ) ; EXPECT_NEAR ( 1.f , aabb -> max . y , kEpsilon ) ; layout_box_system_ -> SetDesiredSize ( parent , kNullEntity , 1.f , 1.f , Optional < float > ( ) ) ; dispatcher_ -> Dispatch ( ) ; aabb = layout_box_system_ -> GetActualBox ( parent ) ; EXPECT_NEAR ( -0.5f , aabb -> min . x , kEpsilon ) ; EXPECT_NEAR ( -0.5f , aabb -> min . y , kEpsilon ) ; EXPECT_NEAR ( 0.5f , aabb -> max . x , kEpsilon ) ; EXPECT_NEAR ( 0.5f , aabb -> max . y , kEpsilon ) ; layout_box_system_ -> SetActualBox ( child , kNullEntity , Aabb ( { 0.1f , 0.1f , 0.f } , { 0.1f , 0.1f , 0.f } ) ) ; dispatcher_ -> Dispatch ( ) ; aabb = layout_box_system_ -> GetActualBox ( parent ) ; EXPECT_NEAR ( -0.5f , aabb -> min . x , kEpsilon ) ; EXPECT_NEAR ( -0.5f , aabb -> min . y , kEpsilon ) ; EXPECT_NEAR ( 0.5f , aabb -> max . x , kEpsilon ) ; EXPECT_NEAR ( 0.5f , aabb -> max . y , kEpsilon ) ; }
Test that the LayoutSystem will use the previously set DesiredSize even in
subsequent ActualBoxChangedEvents, supporting asynchronous mesh generators.
Test that the LayoutSystem will use the previously set DesiredSize even in subsequent ActualBoxChangedEvents supporting asynchronous mesh generators .