Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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:24
constexpr const char * kDefaultAOTAppELFFileName
Definition: elf_loader.h:17

◆ 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_
Definition: dart_fixture.h:37
ELFAOTSymbols split_aot_symbols_
Definition: dart_fixture.h:38
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:17
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:66
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 80 of file dart_fixture.cc.

81 {
82 native_resolver_->AddFfiNativeCallback(name, callback_ptr);
83}
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ AddNativeCallback()

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

Definition at line 75 of file dart_fixture.cc.

76 {
77 native_resolver_->AddNativeCallback(name, callback);
78}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ 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&) {};
34 settings.task_observer_remove = [](intptr_t) {};
35 settings.isolate_create_callback = [this]() {
36 native_resolver_->SetNativeResolverForIsolate();
37 };
38 settings.enable_vm_service = false;
40 return settings;
41}
void SetSnapshotsAndAssets(Settings &settings)
Definition: dart_fixture.cc:43
std::function< void()> closure
Definition: closure.h:14

◆ SetSnapshotsAndAssets()

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

Definition at line 43 of file dart_fixture.cc.

43 {
44 if (!assets_dir_.is_valid()) {
45 return;
46 }
47
48 settings.assets_dir = assets_dir_.get();
49
50 // In JIT execution, all snapshots are present within the binary itself and
51 // don't need to be explicitly supplied by the embedder. In AOT, these
52 // snapshots will be present in the application AOT dylib.
55#if FML_OS_LINUX
56 settings.vmservice_snapshot_library_path.emplace_back(fml::paths::JoinPaths(
57 {GetTestingAssetsPath(), "libvmservice_snapshot.so"}));
58#endif // FML_OS_LINUX
59 } else {
60 settings.application_kernels = [this]() -> Mappings {
61 std::vector<std::unique_ptr<const fml::Mapping>> kernel_mappings;
62 auto kernel_mapping =
64 if (!kernel_mapping || !kernel_mapping->IsValid()) {
65 FML_LOG(ERROR) << "Could not find kernel blob for test fixture not "
66 "running in precompiled mode.";
67 return kernel_mappings;
68 }
69 kernel_mappings.emplace_back(std::move(kernel_mapping));
70 return kernel_mappings;
71 };
72 }
73}
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:205
static std::unique_ptr< FileMapping > CreateReadOnly(const std::string &path)
Definition: mapping.cc:20
bool is_valid() const
Definition: unique_object.h:89
const T & get() const
Definition: unique_object.h:87
#define FML_LOG(severity)
Definition: logging.h:82
#define FML_CHECK(condition)
Definition: logging.h:85
bool PrepareSettingsForAOTWithSymbols(Settings &settings, const ELFAOTSymbols &symbols)
Prepare the settings objects various AOT mappings resolvers with the symbols already loaded....
Definition: elf_loader.cc:116
const char * GetTestingAssetsPath()
Returns the directory containing assets shared across all tests.
std::vector< std::unique_ptr< const fml::Mapping > > Mappings
Definition: settings.h:94
std::string JoinPaths(std::initializer_list< std::string > components)
Definition: paths.cc:14
#define ERROR(message)
Definition: elf_loader.cc:260

Member Data Documentation

◆ aot_symbols_

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

Definition at line 42 of file dart_fixture.h.

◆ assets_dir_

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

Definition at line 41 of file dart_fixture.h.

◆ 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.

◆ native_resolver_

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

Definition at line 37 of file dart_fixture.h.

◆ 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: