Flutter Engine
 
Loading...
Searching...
No Matches
flutter::testing::DartFixture Class Reference

#include <dart_fixture.h>

Inheritance diagram for flutter::testing::DartFixture:
flutter::testing::DartNativeBenchmarks flutter::testing::FixtureTest impeller::testing::RendererDartTest flutter::Fixture flutter::testing::DartIsolateTest flutter::testing::DartIsolateTest flutter::testing::DartIsolateTest flutter::testing::DartPersistentHandleTest flutter::testing::DartSecondaryIsolateTest flutter::testing::DartWeakPersistentHandle flutter::testing::FfiNativeTest flutter::testing::ImageDecoderFixtureTest flutter::testing::IsolateStartupFailureTest flutter::testing::PlatformIsolateManagerTest flutter::testing::ShellIOManagerTest flutter::testing::ShellTest flutter::testing::TypeConversionsTest

Public Member Functions

 DartFixture ()
 
 DartFixture (std::string kernel_filename, std::string elf_filename, std::string elf_split_filename)
 
virtual Settings CreateSettingsForFixture ()
 
void AddNativeCallback (const std::string &name, Dart_NativeFunction callback)
 
void AddFfiNativeCallback (const std::string &name, void *callback_ptr)
 

Protected Member Functions

void SetSnapshotsAndAssets (Settings &settings)
 

Protected Attributes

std::shared_ptr< TestDartNativeResolvernative_resolver_
 
ELFAOTSymbols split_aot_symbols_
 
std::string kernel_filename_
 
std::string elf_filename_
 
fml::UniqueFD assets_dir_
 
ELFAOTSymbols aot_symbols_
 

Detailed Description

Definition at line 19 of file dart_fixture.h.

Constructor & Destructor Documentation

◆ DartFixture() [1/2]

flutter::testing::DartFixture::DartFixture ( )

Definition at line 12 of file dart_fixture.cc.

13 : DartFixture("kernel_blob.bin",
constexpr const char * kDefaultAOTAppELFSplitFileName
Definition elf_loader.h:23
constexpr const char * kDefaultAOTAppELFFileName
Definition elf_loader.h:16

◆ DartFixture() [2/2]

flutter::testing::DartFixture::DartFixture ( std::string  kernel_filename,
std::string  elf_filename,
std::string  elf_split_filename 
)

Definition at line 17 of file dart_fixture.cc.

20 : native_resolver_(std::make_shared<TestDartNativeResolver>()),
22 std::move(elf_split_filename))),
23 kernel_filename_(std::move(kernel_filename)),
25 false,
28 LoadELFSymbolFromFixturesIfNeccessary(std::move(elf_filename))) {}
std::shared_ptr< TestDartNativeResolver > native_resolver_
const char * GetFixturesPath()
Returns the directory containing the test fixture for the target if this target has fixtures configur...
ELFAOTSymbols LoadELFSymbolFromFixturesIfNeccessary(std::string elf_filename)
Attempts to resolve AOT symbols from the portable ELF loader. This location is automatically resolved...
Definition elf_loader.cc:16
ELFAOTSymbols LoadELFSplitSymbolFromFixturesIfNeccessary(std::string elf_split_filename)
Attempts to resolve split loading unit AOT symbols from the portable ELF loader. If the dart code doe...
Definition elf_loader.cc:65
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
Definition file_posix.cc:97

Member Function Documentation

◆ AddFfiNativeCallback()

void flutter::testing::DartFixture::AddFfiNativeCallback ( const std::string &  name,
void *  callback_ptr 
)

Definition at line 82 of file dart_fixture.cc.

83 {
84 native_resolver_->AddFfiNativeCallback(name, callback_ptr);
85}
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27

References flutter::name, and native_resolver_.

◆ AddNativeCallback()

void flutter::testing::DartFixture::AddNativeCallback ( const std::string &  name,
Dart_NativeFunction  callback 
)

Definition at line 77 of file dart_fixture.cc.

78 {
79 native_resolver_->AddNativeCallback(name, callback);
80}
FlutterDesktopBinaryReply callback

References callback, flutter::name, and native_resolver_.

Referenced by impeller::testing::RendererDartTest::RendererDartTest(), and flutter::testing::TestSimulatedInputEvents().

◆ CreateSettingsForFixture()

Settings flutter::testing::DartFixture::CreateSettingsForFixture ( )
virtual

Reimplemented in flutter::testing::ShellTest.

Definition at line 30 of file dart_fixture.cc.

30 {
31 Settings settings;
32 settings.leak_vm = false;
33 settings.task_observer_add = [](intptr_t, const fml::closure&) {
35 };
36 settings.task_observer_remove = [](fml::TaskQueueId, intptr_t) {};
37 settings.isolate_create_callback = [this]() {
38 native_resolver_->SetNativeResolverForIsolate();
39 };
40 settings.enable_vm_service = false;
41 SetSnapshotsAndAssets(settings);
42 return settings;
43}
void SetSnapshotsAndAssets(Settings &settings)
static TaskQueueId Invalid()
std::function< void()> closure
Definition closure.h:14

References flutter::Settings::enable_vm_service, fml::TaskQueueId::Invalid(), flutter::Settings::isolate_create_callback, flutter::Settings::leak_vm, native_resolver_, SetSnapshotsAndAssets(), flutter::Settings::task_observer_add, and flutter::Settings::task_observer_remove.

Referenced by flutter::BM_PlatformMessageResponseDartComplete(), and flutter::testing::PlatformIsolateManagerTest::TestWithRootIsolate().

◆ SetSnapshotsAndAssets()

void flutter::testing::DartFixture::SetSnapshotsAndAssets ( Settings settings)
protected

Definition at line 45 of file dart_fixture.cc.

45 {
46 if (!assets_dir_.is_valid()) {
47 return;
48 }
49
50 settings.assets_dir = assets_dir_.get();
51
52 // In JIT execution, all snapshots are present within the binary itself and
53 // don't need to be explicitly supplied by the embedder. In AOT, these
54 // snapshots will be present in the application AOT dylib.
57#if FML_OS_LINUX
58 settings.vmservice_snapshot_library_path.emplace_back(fml::paths::JoinPaths(
59 {GetTestingAssetsPath(), "libvmservice_snapshot.so"}));
60#endif // FML_OS_LINUX
61 } else {
62 settings.application_kernels = [this]() -> Mappings {
63 std::vector<std::unique_ptr<const fml::Mapping>> kernel_mappings;
64 auto kernel_mapping =
66 if (!kernel_mapping || !kernel_mapping->IsValid()) {
67 FML_LOG(ERROR) << "Could not find kernel blob for test fixture not "
68 "running in precompiled mode.";
69 return kernel_mappings;
70 }
71 kernel_mappings.emplace_back(std::move(kernel_mapping));
72 return kernel_mappings;
73 };
74 }
75}
static bool IsRunningPrecompiledCode()
Checks if VM instances in the process can run precompiled code. This call can be made at any time and...
Definition dart_vm.cc:176
static std::unique_ptr< FileMapping > CreateReadOnly(const std::string &path)
Definition mapping.cc:20
bool is_valid() const
const T & get() const
#define FML_LOG(severity)
Definition logging.h:101
#define FML_CHECK(condition)
Definition logging.h:104
bool PrepareSettingsForAOTWithSymbols(Settings &settings, const ELFAOTSymbols &symbols)
Prepare the settings objects various AOT mappings resolvers with the symbols already loaded....
const char * GetTestingAssetsPath()
Returns the directory containing assets shared across all tests.
std::vector< std::unique_ptr< const fml::Mapping > > Mappings
Definition settings.h:88
std::string JoinPaths(std::initializer_list< std::string > components)
Definition paths.cc:14

References aot_symbols_, flutter::Settings::application_kernels, flutter::Settings::assets_dir, assets_dir_, fml::FileMapping::CreateReadOnly(), FML_CHECK, FML_LOG, fml::UniqueObject< T, Traits >::get(), flutter::testing::GetTestingAssetsPath(), fml::UniqueObject< T, Traits >::is_valid(), flutter::DartVM::IsRunningPrecompiledCode(), fml::paths::JoinPaths(), kernel_filename_, flutter::testing::PrepareSettingsForAOTWithSymbols(), and flutter::Settings::vmservice_snapshot_library_path.

Referenced by CreateSettingsForFixture().

Member Data Documentation

◆ aot_symbols_

ELFAOTSymbols flutter::testing::DartFixture::aot_symbols_
protected

Definition at line 42 of file dart_fixture.h.

Referenced by SetSnapshotsAndAssets().

◆ assets_dir_

fml::UniqueFD flutter::testing::DartFixture::assets_dir_
protected

Definition at line 41 of file dart_fixture.h.

Referenced by SetSnapshotsAndAssets().

◆ elf_filename_

std::string flutter::testing::DartFixture::elf_filename_
protected

Definition at line 40 of file dart_fixture.h.

◆ kernel_filename_

std::string flutter::testing::DartFixture::kernel_filename_
protected

Definition at line 39 of file dart_fixture.h.

Referenced by SetSnapshotsAndAssets().

◆ native_resolver_

std::shared_ptr<TestDartNativeResolver> flutter::testing::DartFixture::native_resolver_
protected

◆ split_aot_symbols_

ELFAOTSymbols flutter::testing::DartFixture::split_aot_symbols_
protected

Definition at line 38 of file dart_fixture.h.


The documentation for this class was generated from the following files: