5#include "flutter/runtime/dart_vm.h"
6#include "flutter/runtime/dart_vm_lifecycle.h"
7#include "flutter/runtime/platform_isolate_manager.h"
8#include "flutter/testing/fixture_test.h"
9#include "flutter/testing/testing.h"
28 std::unordered_map<Dart_Isolate, std::vector<std::unique_ptr<IsolateData>>>;
44 auto vm_data = vm_ref.GetVMData();
54 auto isolate_configuration =
61 vm_data->GetSettings(),
62 vm_data->GetIsolateSnapshot(),
71 std::move(isolate_configuration),
74 root_isolate_ = weak_isolate.lock()->isolate();
75 ASSERT_TRUE(root_isolate_);
89 char*
error =
nullptr;
92 nullptr, isolate_data, &
error);
93 isolate_data->
isolate = isolate;
98 std::unique_ptr<IsolateData>(isolate_data));
119 static void OnShutdown(
void*,
void* raw_isolate_data) {
134 TestWithRootIsolate([
this]() {
140 ASSERT_TRUE(isolateA);
141 EXPECT_FALSE(IsolateIsShutdown(isolateA));
146 ASSERT_TRUE(isolateB);
147 EXPECT_FALSE(IsolateIsShutdown(isolateB));
163 TestWithRootIsolate([
this]() {
168 ASSERT_TRUE(isolateA);
169 EXPECT_FALSE(IsolateIsShutdown(isolateA));
174 ASSERT_TRUE(isolateB);
175 EXPECT_FALSE(IsolateIsShutdown(isolateB));
200 TestWithRootIsolate([
this]() {
205 ASSERT_TRUE(isolateA);
206 EXPECT_FALSE(IsolateIsShutdown(isolateA));
217 ASSERT_TRUE(isolateB);
218 EXPECT_FALSE(IsolateIsShutdown(isolateB));
219 EXPECT_FALSE(IsolateWasRegistered(isolateB));
232 TestWithRootIsolate([
this]() {
236 std::atomic<bool> test_finished =
false;
237 std::vector<std::thread> threads;
239 for (
int i = 0;
i < 10; ++
i) {
240 threads.push_back(std::thread([
this, &mgr, &test_finished]() {
241 for (
int j = 0; j < 100; ++j) {
243 ASSERT_TRUE(isolate);
245 if (!IsolateWasRegistered(isolate)) {
250 while (!test_finished.load()) {
260 test_finished =
true;
261 for (
auto& thread : threads) {
static std::weak_ptr< DartIsolate > CreateRunningRootIsolate(const Settings &settings, const fml::RefPtr< const DartSnapshot > &isolate_snapshot, std::unique_ptr< PlatformConfiguration > platform_configuration, Flags flags, const fml::closure &root_isolate_create_callback, const fml::closure &isolate_create_callback, const fml::closure &isolate_shutdown_callback, std::optional< std::string > dart_entrypoint, std::optional< std::string > dart_entrypoint_library, const std::vector< std::string > &dart_entrypoint_args, std::unique_ptr< IsolateConfiguration > isolate_configuration, const UIDartState::Context &context, const DartIsolate *spawning_isolate=nullptr)
Creates an instance of a root isolate and returns a weak pointer to the same. The isolate instance ma...
static DartVMRef Create(const Settings &settings, fml::RefPtr< const DartSnapshot > vm_snapshot=nullptr, fml::RefPtr< const DartSnapshot > isolate_snapshot=nullptr)
static bool IsInstanceRunning()
static std::unique_ptr< IsolateConfiguration > InferFromSettings(const Settings &settings, const std::shared_ptr< AssetManager > &asset_manager=nullptr, const fml::RefPtr< fml::TaskRunner > &io_worker=nullptr, IsolateLaunchType launch_type=IsolateLaunchType::kNewGroup)
Attempts to infer the isolate configuration from the Settings object. If the VM is configured for AOT...
virtual Settings CreateSettingsForFixture()
fml::RefPtr< fml::TaskRunner > GetCurrentTaskRunner()
Get the task runner for the thread that the current unit-test is running on. This creates a message l...
DART_EXPORT void Dart_ShutdownIsolate(void)
DART_EXPORT Dart_Isolate Dart_CreateIsolateInGroup(Dart_Isolate group_member, const char *name, Dart_IsolateShutdownCallback shutdown_callback, Dart_IsolateCleanupCallback cleanup_callback, void *child_isolate_data, char **error)
struct _Dart_Isolate * Dart_Isolate
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate)
DART_EXPORT void Dart_ExitIsolate(void)
const uint8_t uint32_t uint32_t GError ** error
Dart_NativeFunction function
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
TEST_F(DisplayListTest, Defaults)
std::unordered_map< Dart_Isolate, std::vector< std::unique_ptr< IsolateData > > > IsolateDataMap
static thread_local std::unique_ptr< IsolateDataMap > isolate_data_map_
The subset of state which is owned by the shell or engine and passed through the RuntimeController in...
std::string advisory_script_uri
std::string advisory_script_entrypoint
PlatformIsolateManager * mgr
IsolateData(PlatformIsolateManager *_mgr)
#define EXPECT_TRUE(handle)