lullaby/tests/layout_system_test.cc
// Test that LayoutSystem will resize weighted elements, including other
// Layouts that will resize their children.
// Parent canvas_size = (2,2)
//   Child [0], size = (1,0)
//   Child [1], weighted, becomes size = (1,0)
//     Grandchild [2], weighted, becomes size = (0.5,0)
//     Grandchild [3], weighted, also becomes size = (0.5,0)
Test that LayoutSystem will resize weighted elements, including other
Layouts that will resize their children.
Test that LayoutSystem will resize weighted elements including other Layouts that will resize their children .
TEST_F(LayoutSystemTest, CreateLayout_WeightedElements_Nested) {
  const mathfu::vec2 expectations[] = {
      mathfu::vec2(-0.5f, 1.f), mathfu::vec2(0.5f, 1.f),
      mathfu::vec2(-0.25f, 0.f), mathfu::vec2(0.25f, 0.f),
  };
  const mathfu::vec2 size_expectations[] = {
      mathfu::vec2(1.f, 0.f), mathfu::vec2(1.f, 0.f),
      mathfu::vec2(0.5f, 0.f), mathfu::vec2(0.5f, 0.f),
  };
  const int num_children = 4;
  const Entity parent = CreateParent();
  Entity children[num_children];
  children[0] = CreateChild(parent);
  Aabb aabb;
  aabb.min = mathfu::vec3(-0.5f, 0.f, 0.f);
  aabb.max = mathfu::vec3(0.5f, 0.f, 0.f);
  layout_box_system_->SetOriginalBox(children[0], aabb);
  children[1] = CreateChild(parent, 1.0f, true);
  for (int i = 2; i < num_children; ++i) {
    children[i] = CreateChild(children[1], 1.0f, true);
  }
  AssertTranslationsAndSizes(num_children, children, expectations,
                             size_expectations);
  layout_box_system_->SetActualBox(children[2], kNullEntity,
                                   Aabb({-0.25f, 0.f, 0.f}, {0.25f, 0.f, 0.f}));
  AssertTranslationsAndSizes(num_children, children, expectations,
                             size_expectations);
}
TEST_F ( LayoutSystemTest , CreateLayout_WeightedElements_Nested ) { const mathfu :: vec2 expectations [ ] = { mathfu :: vec2 ( -0.5f , 1.f ) , mathfu :: vec2 ( 0.5f , 1.f ) , mathfu :: vec2 ( -0.25f , 0.f ) , mathfu :: vec2 ( 0.25f , 0.f ) , } ; const mathfu :: vec2 size_expectations [ ] = { mathfu :: vec2 ( 1.f , 0.f ) , mathfu :: vec2 ( 1.f , 0.f ) , mathfu :: vec2 ( 0.5f , 0.f ) , mathfu :: vec2 ( 0.5f , 0.f ) , } ; const int num_children = 4 ; const Entity parent = CreateParent ( ) ; Entity children [ num_children ] ; children [ 0 ] = CreateChild ( parent ) ; Aabb aabb ; aabb . min = mathfu :: vec3 ( -0.5f , 0.f , 0.f ) ; aabb . max = mathfu :: vec3 ( 0.5f , 0.f , 0.f ) ; layout_box_system_ -> SetOriginalBox ( children [ 0 ] , aabb ) ; children [ 1 ] = CreateChild ( parent , 1.0f , true ) ; for ( int i = 2 ; i < num_children ; ++ i ) { children [ i ] = CreateChild ( children [ 1 ] , 1.0f , true ) ; } AssertTranslationsAndSizes ( num_children , children , expectations , size_expectations ) ; layout_box_system_ -> SetActualBox ( children [ 2 ] , kNullEntity , Aabb ( { -0.25f , 0.f , 0.f } , { 0.25f , 0.f , 0.f } ) ) ; AssertTranslationsAndSizes ( num_children , children , expectations , size_expectations ) ; }
Test that LayoutSystem will resize weighted elements, including other
Layouts that will resize their children.
Test that LayoutSystem will resize weighted elements including other Layouts that will resize their children .
// They should be arranged in the following manner in 2 columns. //  0   1  (no height, so 2/3 are inside 1 at the same y) //     2 3 //  -   - // [2] and [3] are relative to [1]'s coordinates. // Child [0], fixed size (1,0) in left column. // Child [1], has weight, will weighted to (1,0) on the right column. // The LayoutDef will change the child's size. // Grandchild [2] and [3] of [1], have weight, will be both weighted to // (0.5,0) inside of [1]. // The LayoutDef will change the child's size. // In addition, if there was an asynchronous mesh generator that SetActualBox // in a later frame, the Layouts should still use their previously set // desired_size.