@@ -2438,39 +2438,61 @@ TEST_F(ShellTest, Spawn) {
24382438 ASSERT_TRUE (configuration.IsValid ());
24392439 configuration.SetEntrypoint (" fixturesAreFunctionalMain" );
24402440
2441+ auto second_configuration = RunConfiguration::InferFromSettings (settings);
2442+ ASSERT_TRUE (second_configuration.IsValid ());
2443+ second_configuration.SetEntrypoint (" testCanLaunchSecondaryIsolate" );
2444+
24412445 fml::AutoResetWaitableEvent main_latch;
2446+ std::string last_entry_point;
2447+ // Fulfill native function for the first Shell's entrypoint.
24422448 AddNativeCallback (
2443- " SayHiFromFixturesAreFunctionalMain" ,
2444- CREATE_NATIVE_ENTRY ([&main_latch](auto args) { main_latch.Signal (); }));
2449+ " SayHiFromFixturesAreFunctionalMain" , CREATE_NATIVE_ENTRY ([&](auto args) {
2450+ last_entry_point = shell->GetEngine ()->GetLastEntrypoint ();
2451+ main_latch.Signal ();
2452+ }));
2453+ // Fulfill native function for the second Shell's entrypoint.
2454+ AddNativeCallback (
2455+ // The Dart native function names aren't very consistent but this is just
2456+ // the native function name of the second vm entrypoint in the fixture.
2457+ " NotifyNative" , CREATE_NATIVE_ENTRY ([&](auto args) {}));
24452458
24462459 RunEngine (shell.get (), std::move (configuration));
24472460 main_latch.Wait ();
24482461 ASSERT_TRUE (DartVMRef::IsInstanceRunning ());
2462+ // Check first Shell ran the first entrypoint.
2463+ ASSERT_EQ (" fixturesAreFunctionalMain" , last_entry_point);
24492464
2450- PostSync (shell->GetTaskRunners ().GetPlatformTaskRunner (), [this ,
2451- &spawner = shell,
2452- settings]() {
2453- MockPlatformViewDelegate platform_view_delegate;
2454- auto spawn = spawner->Spawn (
2455- settings,
2456- [&platform_view_delegate](Shell& shell) {
2457- auto result = std::make_unique<MockPlatformView>(
2458- platform_view_delegate, shell.GetTaskRunners ());
2459- ON_CALL (*result, CreateRenderingSurface ())
2460- .WillByDefault (::testing::Invoke (
2461- [] { return std::make_unique<MockSurface>(); }));
2462- return result;
2463- },
2464- [](Shell& shell) { return std::make_unique<Rasterizer>(shell); });
2465- ASSERT_NE (nullptr , spawn.get ());
2466- ASSERT_TRUE (ValidateShell (spawn.get ()));
2467-
2468- PostSync (spawner->GetTaskRunners ().GetIOTaskRunner (), [&spawner, &spawn] {
2469- ASSERT_EQ (spawner->GetIOManager ()->GetResourceContext ().get (),
2470- spawn->GetIOManager ()->GetResourceContext ().get ());
2471- });
2472- DestroyShell (std::move (spawn));
2473- });
2465+ PostSync (
2466+ shell->GetTaskRunners ().GetPlatformTaskRunner (),
2467+ [this , &spawner = shell, &second_configuration]() {
2468+ MockPlatformViewDelegate platform_view_delegate;
2469+ auto spawn = spawner->Spawn (
2470+ std::move (second_configuration),
2471+ [&platform_view_delegate](Shell& shell) {
2472+ auto result = std::make_unique<MockPlatformView>(
2473+ platform_view_delegate, shell.GetTaskRunners ());
2474+ ON_CALL (*result, CreateRenderingSurface ())
2475+ .WillByDefault (::testing::Invoke (
2476+ [] { return std::make_unique<MockSurface>(); }));
2477+ return result;
2478+ },
2479+ [](Shell& shell) { return std::make_unique<Rasterizer>(shell); });
2480+ ASSERT_NE (nullptr , spawn.get ());
2481+ ASSERT_TRUE (ValidateShell (spawn.get ()));
2482+
2483+ PostSync (spawner->GetTaskRunners ().GetUITaskRunner (), [&spawn] {
2484+ // Check second shell ran the second entrypoint.
2485+ ASSERT_EQ (" testCanLaunchSecondaryIsolate" ,
2486+ spawn->GetEngine ()->GetLastEntrypoint ());
2487+ });
2488+
2489+ PostSync (
2490+ spawner->GetTaskRunners ().GetIOTaskRunner (), [&spawner, &spawn] {
2491+ ASSERT_EQ (spawner->GetIOManager ()->GetResourceContext ().get (),
2492+ spawn->GetIOManager ()->GetResourceContext ().get ());
2493+ });
2494+ DestroyShell (std::move (spawn));
2495+ });
24742496
24752497 DestroyShell (std::move (shell));
24762498 ASSERT_FALSE (DartVMRef::IsInstanceRunning ());
0 commit comments