src/modular/tests/agent_session_restart_test.cc
// Test that an Agent can use the SessionRestartController protocol to restart the session.
Test that an Agent can use the SessionRestartController protocol to restart the session.
Test that an Agent can use the SessionRestartController protocol to restart the session .
TEST_F(AgentSessionRestartTest, AgentCanRestartSession) {
  auto agent = modular_testing::FakeAgent::CreateWithDefaultOptions();
  auto session_shell = modular_testing::FakeSessionShell::CreateWithDefaultOptions();
  fuchsia::modular::testing::TestHarnessSpec spec;
  spec.mutable_sessionmgr_config()->mutable_session_agents()->push_back(agent->url());
  modular_testing::TestHarnessBuilder builder(std::move(spec));
  builder.InterceptSessionShell(session_shell->BuildInterceptOptions());
  builder.InterceptComponent(AddSandboxServices({fuchsia::modular::SessionRestartController::Name_},
                                                agent->BuildInterceptOptions()));
  builder.BuildAndRun(test_harness());
  RunLoopUntil([&] { return session_shell->is_running() && agent->is_running(); });
  auto session_restart_controller =
      agent->component_context()->svc()->Connect<fuchsia::modular::SessionRestartController>();
  session_restart_controller->Restart();
  RunLoopUntil([&] { return !session_shell->is_running(); });
  RunLoopUntil([&] { return session_shell->is_running(); });
}
TEST_F ( AgentSessionRestartTest , AgentCanRestartSession ) { auto agent = modular_testing :: FakeAgent :: CreateWithDefaultOptions ( ) ; auto session_shell = modular_testing :: FakeSessionShell :: CreateWithDefaultOptions ( ) ; fuchsia :: modular :: testing :: TestHarnessSpec spec ; spec . mutable_sessionmgr_config ( ) -> mutable_session_agents ( ) -> push_back ( agent -> url ( ) ) ; modular_testing :: TestHarnessBuilder builder ( std :: move ( spec ) ) ; builder . InterceptSessionShell ( session_shell -> BuildInterceptOptions ( ) ) ; builder . InterceptComponent ( AddSandboxServices ( { fuchsia :: modular :: SessionRestartController :: Name_ } , agent -> BuildInterceptOptions ( ) ) ) ; builder . BuildAndRun ( test_harness ( ) ) ; RunLoopUntil ( [ & ] { return session_shell -> is_running ( ) && agent -> is_running ( ) ; } ) ; auto session_restart_controller = agent -> component_context ( ) -> svc ( ) -> Connect < fuchsia :: modular :: SessionRestartController > ( ) ; session_restart_controller -> Restart ( ) ; RunLoopUntil ( [ & ] { return ! session_shell -> is_running ( ) ; } ) ; RunLoopUntil ( [ & ] { return session_shell -> is_running ( ) ; } ) ; }
Test that an Agent can use the SessionRestartController protocol to restart the session.
Test that an Agent can use the SessionRestartController protocol to restart the session .
// Use the session shell's startup to indicate that the runtime is up. // Issue a restart command from the Agent. // Wait for the session shell to die (indicating a restart), then wait for it to come back.