sdk/lib/modular/testing/cpp/fake_component_test.cc
// Tests that FakeComponent publishes & implements fuchsia.modular.Lifecycle.
Tests that FakeComponent publishes & implements fuchsia.modular.Lifecycle.
Tests that FakeComponent publishes & implements fuchsia . modular . Lifecycle .
TEST_F(FakeComponentTest, Lifecyle) {
  modular_testing::TestHarnessBuilder builder;
  modular_testing::FakeComponent session_shell(
      {.url = modular_testing::TestHarnessBuilder::GenerateFakeUrl()});
  builder.InterceptSessionShell(session_shell.BuildInterceptOptions());
  builder.BuildAndRun(test_harness());
  RunLoopUntil([&] { return session_shell.is_running(); });
  zx::channel svc_request, svc_dir;
  ASSERT_EQ(ZX_OK, zx::channel::create(0, &svc_request, &svc_dir));
  session_shell.component_context()->outgoing()->Serve(std::move(svc_request));
  sys::ServiceDirectory svc(std::move(svc_dir));
  fuchsia::modular::LifecyclePtr lifecycle;
  ASSERT_EQ(ZX_OK, svc.Connect(lifecycle.NewRequest(), "svc/fuchsia.modular.Lifecycle"));
  lifecycle->Terminate();
  RunLoopUntil([&] { return !session_shell.is_running(); });
}
TEST_F ( FakeComponentTest , Lifecyle ) { modular_testing :: TestHarnessBuilder builder ; modular_testing :: FakeComponent session_shell ( { . url = modular_testing :: TestHarnessBuilder :: GenerateFakeUrl ( ) } ) ; builder . InterceptSessionShell ( session_shell . BuildInterceptOptions ( ) ) ; builder . BuildAndRun ( test_harness ( ) ) ; RunLoopUntil ( [ & ] { return session_shell . is_running ( ) ; } ) ; zx :: channel svc_request , svc_dir ; ASSERT_EQ ( ZX_OK , zx :: channel :: create ( 0 , & svc_request , & svc_dir ) ) ; session_shell . component_context ( ) -> outgoing ( ) -> Serve ( std :: move ( svc_request ) ) ; sys :: ServiceDirectory svc ( std :: move ( svc_dir ) ) ; fuchsia :: modular :: LifecyclePtr lifecycle ; ASSERT_EQ ( ZX_OK , svc . Connect ( lifecycle . NewRequest ( ) , " " ) ) ; lifecycle -> Terminate ( ) ; RunLoopUntil ( [ & ] { return ! session_shell . is_running ( ) ; } ) ; }
Tests that FakeComponent publishes & implements fuchsia.modular.Lifecycle.
Tests that FakeComponent publishes & implements fuchsia . modular . Lifecycle .
// Serve the outgoing() directory from FakeComponent.