Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
flutter::testing::FfiNativeTest Class Reference
Inheritance diagram for flutter::testing::FfiNativeTest:
flutter::testing::FixtureTest flutter::testing::DartFixture flutter::testing::ThreadTest

Public Member Functions

 FfiNativeTest ()
 
 ~FfiNativeTest ()=default
 
bool RunWithEntrypoint (const std::string &entrypoint)
 
template<typename C , typename Signature , Signature function>
void DoCallThroughTest (const char *testName, const char *testEntry)
 
template<typename C , typename Signature , Signature function>
void DoSerialiseTest (bool leaf, const char *returnFfi, const char *returnDart, const char *argsFfi, const char *argsDart)
 
- Public Member Functions inherited from flutter::testing::FixtureTest
 FixtureTest ()
 
 FixtureTest (std::string kernel_filename, std::string elf_filename, std::string elf_split_filename)
 
- Public Member Functions inherited from flutter::testing::DartFixture
 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)
 
- Public Member Functions inherited from flutter::testing::ThreadTest
 ThreadTest ()
 
fml::RefPtr< fml::TaskRunnerGetCurrentTaskRunner ()
 Get the task runner for the thread that the current unit-test is running on. This creates a message loop as necessary. More...
 
fml::RefPtr< fml::TaskRunnerCreateNewThread (const std::string &name="")
 Creates a new thread, initializes a message loop on it, and, returns its task runner to the unit-test. The message loop is terminated (and its thread joined) when the test ends. This allows tests to create multiple named threads as necessary. More...
 

Protected Member Functions

 FML_DISALLOW_COPY_AND_ASSIGN (FfiNativeTest)
 
- Protected Member Functions inherited from flutter::testing::DartFixture
void SetSnapshotsAndAssets (Settings &settings)
 

Protected Attributes

Settings settings_
 
DartVMRef vm_
 
std::unique_ptr< AutoIsolateShutdownrunning_isolate_
 
fml::RefPtr< fml::TaskRunnerthread_
 
TaskRunners task_runners_
 
- Protected Attributes inherited from flutter::testing::DartFixture
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 41 of file ffi_native_unittest.cc.

Constructor & Destructor Documentation

◆ FfiNativeTest()

flutter::testing::FfiNativeTest::FfiNativeTest ( )
inline

Definition at line 43 of file ffi_native_unittest.cc.

48 thread_,
49 thread_,
50 thread_,
51 thread_) {}
static DartVMRef Create(const Settings &settings, fml::RefPtr< const DartSnapshot > vm_snapshot=nullptr, fml::RefPtr< const DartSnapshot > isolate_snapshot=nullptr)
virtual Settings CreateSettingsForFixture()
Definition: dart_fixture.cc:30
fml::RefPtr< fml::TaskRunner > thread_
fml::RefPtr< fml::TaskRunner > CreateNewThread(const std::string &name="")
Creates a new thread, initializes a message loop on it, and, returns its task runner to the unit-test...
Definition: thread_test.cc:26
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
Definition: testing.cc:15

◆ ~FfiNativeTest()

flutter::testing::FfiNativeTest::~FfiNativeTest ( )
default

Member Function Documentation

◆ DoCallThroughTest()

template<typename C , typename Signature , Signature function>
void flutter::testing::FfiNativeTest::DoCallThroughTest ( const char *  testName,
const char *  testEntry 
)
inline

Definition at line 71 of file ffi_native_unittest.cc.

71 {
72 auto weak_persistent_value = tonic::DartWeakPersistentValue();
73
75
77 testName, reinterpret_cast<void*>(
79
81 "CreateNative",
82 reinterpret_cast<void*>(
84 &MyNativeClass::Create>::Call));
85
86 AddNativeCallback("SignalDone",
88 // Clear on initiative of Dart.
89 weak_persistent_value.Clear();
90
91 event.Signal();
92 }));
93
94 ASSERT_TRUE(RunWithEntrypoint(testEntry));
95 event.Wait();
96
97 running_isolate_->Shutdown();
98 }
void AddFfiNativeCallback(const std::string &name, void *callback_ptr)
Definition: dart_fixture.cc:80
void AddNativeCallback(const std::string &name, Dart_NativeFunction callback)
Definition: dart_fixture.cc:75
bool RunWithEntrypoint(const std::string &entrypoint)
std::unique_ptr< AutoIsolateShutdown > running_isolate_
static void Create(Dart_Handle path_handle, intptr_t value)
struct _Dart_NativeArguments * Dart_NativeArguments
Definition: dart_api.h:3019
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent * event
#define CREATE_NATIVE_ENTRY(native_entry)

◆ DoSerialiseTest()

template<typename C , typename Signature , Signature function>
void flutter::testing::FfiNativeTest::DoSerialiseTest ( bool  leaf,
const char *  returnFfi,
const char *  returnDart,
const char *  argsFfi,
const char *  argsDart 
)
inline

Definition at line 101 of file ffi_native_unittest.cc.

105 {
107
108 EXPECT_EQ(dispatcher.AllowedAsLeafCall(), leaf);
109 EXPECT_STREQ(dispatcher.GetReturnFfiRepresentation(), returnFfi);
110 EXPECT_STREQ(dispatcher.GetReturnDartRepresentation(), returnDart);
111
112 {
113 std::ostringstream stream_;
114 dispatcher.WriteFfiArguments(&stream_);
115 EXPECT_STREQ(stream_.str().c_str(), argsFfi);
116 }
117
118 {
119 std::ostringstream stream_;
120 dispatcher.WriteDartArguments(&stream_);
121 EXPECT_STREQ(stream_.str().c_str(), argsDart);
122 }
123 }

◆ FML_DISALLOW_COPY_AND_ASSIGN()

flutter::testing::FfiNativeTest::FML_DISALLOW_COPY_AND_ASSIGN ( FfiNativeTest  )
protected

◆ RunWithEntrypoint()

bool flutter::testing::FfiNativeTest::RunWithEntrypoint ( const std::string &  entrypoint)
inline

Definition at line 55 of file ffi_native_unittest.cc.

55 {
56 if (running_isolate_) {
57 return false;
58 }
59 auto isolate =
62 if (!isolate || isolate->get()->GetPhase() != DartIsolate::Phase::Running) {
63 return false;
64 }
65
66 running_isolate_ = std::move(isolate);
67 return true;
68 }
std::string GetDefaultKernelFilePath()
Returns the default path to kernel_blob.bin. This file is within the directory returned by GetFixture...
Definition: testing.cc:19
std::unique_ptr< AutoIsolateShutdown > RunDartCodeInIsolate(DartVMRef &vm_ref, const Settings &settings, const TaskRunners &task_runners, std::string entrypoint, const std::vector< std::string > &args, const std::string &kernel_file_path, fml::WeakPtr< IOManager > io_manager, std::shared_ptr< VolatilePathTracker > volatile_path_tracker, std::unique_ptr< PlatformConfiguration > platform_configuration)

Member Data Documentation

◆ running_isolate_

std::unique_ptr<AutoIsolateShutdown> flutter::testing::FfiNativeTest::running_isolate_
protected

Definition at line 128 of file ffi_native_unittest.cc.

◆ settings_

Settings flutter::testing::FfiNativeTest::settings_
protected

Definition at line 126 of file ffi_native_unittest.cc.

◆ task_runners_

TaskRunners flutter::testing::FfiNativeTest::task_runners_
protected

Definition at line 130 of file ffi_native_unittest.cc.

◆ thread_

fml::RefPtr<fml::TaskRunner> flutter::testing::FfiNativeTest::thread_
protected

Definition at line 129 of file ffi_native_unittest.cc.

◆ vm_

DartVMRef flutter::testing::FfiNativeTest::vm_
protected

Definition at line 127 of file ffi_native_unittest.cc.


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