src/ui/scenic/lib/flatland/tests/flatland_unittest.cc
// This test doesn't use the helper function to create a link, because it tests intermediate steps
// and timing corner cases.
This test doesn't use the helper function to create a link, because it tests intermediate steps
and timing corner cases.
This test doesn ' t use the helper function to create a link because it tests intermediate steps and timing corner cases .
TEST_F(FlatlandTest, ValidChildToParentFlow) {
  Flatland parent = CreateFlatland();
  Flatland child = CreateFlatland();
  ContentLinkToken parent_token;
  GraphLinkToken child_token;
  ASSERT_EQ(ZX_OK, zx::eventpair::create(0, &parent_token.value, &child_token.value));
  const TransformId kTransformId = 1;
  const ContentId kLinkId = 2;
  parent.CreateTransform(kTransformId);
  parent.SetRootTransform(kTransformId);
  fidl::InterfacePtr<ContentLink> content_link;
  LinkProperties properties;
  properties.set_logical_size({1.0f, 2.0f});
  parent.CreateLink(kLinkId, std::move(parent_token), std::move(properties),
                    content_link.NewRequest());
  parent.SetContentOnTransform(kLinkId, kTransformId);
  fidl::InterfacePtr<GraphLink> graph_link;
  child.LinkToParent(std::move(child_token), graph_link.NewRequest());
  bool status_updated = false;
  content_link->GetStatus([&](ContentLinkStatus status) {
    ASSERT_EQ(ContentLinkStatus::CONTENT_HAS_PRESENTED, status);
    status_updated = true;
  });
  EXPECT_FALSE(status_updated);
  PRESENT(parent, true);
  ProcessMainLoop(parent.GetRoot());
  PRESENT(child, true);
  EXPECT_FALSE(status_updated);
  ProcessMainLoop(parent.GetRoot());
  EXPECT_TRUE(status_updated);
}
TEST_F ( FlatlandTest , ValidChildToParentFlow ) { Flatland parent = CreateFlatland ( ) ; Flatland child = CreateFlatland ( ) ; ContentLinkToken parent_token ; GraphLinkToken child_token ; ASSERT_EQ ( ZX_OK , zx :: eventpair :: create ( 0 , & parent_token . value , & child_token . value ) ) ; const TransformId kTransformId = 1 ; const ContentId kLinkId = 2 ; parent . CreateTransform ( kTransformId ) ; parent . SetRootTransform ( kTransformId ) ; fidl :: InterfacePtr < ContentLink > content_link ; LinkProperties properties ; properties . set_logical_size ( { 1.0f , 2.0f } ) ; parent . CreateLink ( kLinkId , std :: move ( parent_token ) , std :: move ( properties ) , content_link . NewRequest ( ) ) ; parent . SetContentOnTransform ( kLinkId , kTransformId ) ; fidl :: InterfacePtr < GraphLink > graph_link ; child . LinkToParent ( std :: move ( child_token ) , graph_link . NewRequest ( ) ) ; bool status_updated = false ; content_link -> GetStatus ( [ & ] ( ContentLinkStatus status ) { ASSERT_EQ ( ContentLinkStatus :: CONTENT_HAS_PRESENTED , status ) ; status_updated = true ; } ) ; EXPECT_FALSE ( status_updated ) ; PRESENT ( parent , true ) ; ProcessMainLoop ( parent . GetRoot ( ) ) ; PRESENT ( child , true ) ; EXPECT_FALSE ( status_updated ) ; ProcessMainLoop ( parent . GetRoot ( ) ) ; EXPECT_TRUE ( status_updated ) ; }
This test doesn't use the helper function to create a link, because it tests intermediate steps
and timing corner cases.
This test doesn ' t use the helper function to create a link because it tests intermediate steps and timing corner cases .
// The content link status cannot change until both parties have presented -- the parent Flatland // instance must Present() so that the graph is part of the global topology, and the child // Flatland instance must Present() so that CONTENT_HAS_PRESENTED can be true.