lullaby/tests/layout_system_test.cc
// Test that LayoutSystem ignores disabled elements and also updates when the
// enabled status changes.
Test that LayoutSystem ignores disabled elements and also updates when the
enabled status changes.
Test that LayoutSystem ignores disabled elements and also updates when the enabled status changes .
TEST_F(LayoutSystemTest, CreateLayout_WeightedElementsChanging) {
     012   (1 disabled, 0 and 2 grew)
  const mathfu::vec2 expectations[] = {
      mathfu::vec2(-1.f, 1.f),
      mathfu::vec2(0.f, 1.f),
      mathfu::vec2(1.f, 1.f),
  };
  const mathfu::vec2 size_expectations[] = {
      mathfu::vec2(1.f, 0.f),
      mathfu::vec2(1.f, 0.f),
      mathfu::vec2(1.f, 0.f),
  };
   [1] is unaffected and keeps its previous state.
  const mathfu::vec2 disabled_expectations[] = {
      mathfu::vec2(-0.75f, 1.f),
      mathfu::vec2(0.f, 1.f),
      mathfu::vec2(0.75f, 1.f),
  };
  const mathfu::vec2 disabled_size_expectations[] = {
      mathfu::vec2(1.5f, 0.f),
      mathfu::vec2(1.f, 0.f),
      mathfu::vec2(1.5f, 0.f),
  };
  const Entity parent =
      CreateParent(LayoutIgnoreMode_Disabled, mathfu::vec2(3, 2), 3);
  const int num_children = 3;
  Entity children[num_children];
  for (Entity& child : children) {
     Give all children weight.
     The LayoutDef will change the child's size.
    child = CreateChild(parent, 1.0f, true);
  }
   Resulting children will be all 1 wide into 3 columns.
  AssertTranslationsAndSizes(num_children, children, expectations,
                             size_expectations);
   Resulting children will be all 1.5 wide into 2 columns.
  transform_system_->Disable(children[1]);
  AssertTranslationsAndSizes(num_children, children, disabled_expectations,
                             disabled_size_expectations);
   Return to the old layout
  transform_system_->Enable(children[1]);
  AssertTranslationsAndSizes(num_children, children, expectations,
                             size_expectations);
}
TEST_F ( LayoutSystemTest , CreateLayout_WeightedElementsChanging ) { const mathfu :: vec2 expectations [ ] = { mathfu :: vec2 ( -1.f , 1.f ) , mathfu :: vec2 ( 0.f , 1.f ) , mathfu :: vec2 ( 1.f , 1.f ) , } ; const mathfu :: vec2 size_expectations [ ] = { mathfu :: vec2 ( 1.f , 0.f ) , mathfu :: vec2 ( 1.f , 0.f ) , mathfu :: vec2 ( 1.f , 0.f ) , } ; const mathfu :: vec2 disabled_expectations [ ] = { mathfu :: vec2 ( -0.75f , 1.f ) , mathfu :: vec2 ( 0.f , 1.f ) , mathfu :: vec2 ( 0.75f , 1.f ) , } ; const mathfu :: vec2 disabled_size_expectations [ ] = { mathfu :: vec2 ( 1.5f , 0.f ) , mathfu :: vec2 ( 1.f , 0.f ) , mathfu :: vec2 ( 1.5f , 0.f ) , } ; const Entity parent = CreateParent ( LayoutIgnoreMode_Disabled , mathfu :: vec2 ( 3 , 2 ) , 3 ) ; const int num_children = 3 ; Entity children [ num_children ] ; for ( Entity & child : children ) { child = CreateChild ( parent , 1.0f , true ) ; } AssertTranslationsAndSizes ( num_children , children , expectations , size_expectations ) ; transform_system_ -> Disable ( children [ 1 ] ) ; AssertTranslationsAndSizes ( num_children , children , disabled_expectations , disabled_size_expectations ) ; transform_system_ -> Enable ( children [ 1 ] ) ; AssertTranslationsAndSizes ( num_children , children , expectations , size_expectations ) ; }
Test that LayoutSystem ignores disabled elements and also updates when the
enabled status changes.
Test that LayoutSystem ignores disabled elements and also updates when the enabled status changes .
// Canvas_size = (3,2) and elements_per_wrap = 3 // They should be arranged in the following manner. //  0 1 2 //  - - - // //   012   (1 disabled, 0 and 2 grew) //  - - - // [1] is unaffected and keeps its previous state. // Give all children weight. // The LayoutDef will change the child's size. // Resulting children will be all 1 wide into 3 columns. // Resulting children will be all 1.5 wide into 2 columns. // Return to the old layout