Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::testing::WindowsConfigBuilder Class Reference

#include <windows_test_config_builder.h>

Public Member Functions

 WindowsConfigBuilder (WindowsTestContext &context)
 
 ~WindowsConfigBuilder ()
 
FlutterDesktopEngineProperties GetEngineProperties () const
 
void SetDartEntrypoint (std::string_view entrypoint)
 
void AddDartEntrypointArgument (std::string_view arg)
 
EnginePtr InitializeEngine () const
 
EnginePtr RunHeadless () const
 
ViewControllerPtr Run () const
 

Detailed Description

Definition at line 47 of file windows_test_config_builder.h.

Constructor & Destructor Documentation

◆ WindowsConfigBuilder()

flutter::testing::WindowsConfigBuilder::WindowsConfigBuilder ( WindowsTestContext context)
explicit

Definition at line 21 of file windows_test_config_builder.cc.

22 : context_(context) {}

◆ ~WindowsConfigBuilder()

flutter::testing::WindowsConfigBuilder::~WindowsConfigBuilder ( )
default

Member Function Documentation

◆ AddDartEntrypointArgument()

void flutter::testing::WindowsConfigBuilder::AddDartEntrypointArgument ( std::string_view  arg)

Definition at line 33 of file windows_test_config_builder.cc.

33 {
34 if (arg.empty()) {
35 return;
36 }
37
38 dart_entrypoint_arguments_.emplace_back(std::move(arg));
39}

◆ GetEngineProperties()

FlutterDesktopEngineProperties flutter::testing::WindowsConfigBuilder::GetEngineProperties ( ) const

Definition at line 41 of file windows_test_config_builder.cc.

42 {
43 FlutterDesktopEngineProperties engine_properties = {};
44 engine_properties.assets_path = context_.GetAssetsPath().c_str();
45 engine_properties.icu_data_path = context_.GetIcuDataPath().c_str();
46
47 // Set Dart entrypoint.
48 engine_properties.dart_entrypoint = dart_entrypoint_.c_str();
49
50 // Set Dart entrypoint argc, argv.
51 std::vector<const char*> dart_args;
52 dart_args.reserve(dart_entrypoint_arguments_.size());
53 for (const auto& arg : dart_entrypoint_arguments_) {
54 dart_args.push_back(arg.c_str());
55 }
56 if (!dart_args.empty()) {
57 engine_properties.dart_entrypoint_argv = dart_args.data();
58 engine_properties.dart_entrypoint_argc = dart_args.size();
59 } else {
60 // Clear this out in case this is not the first engine launch from the
61 // embedder config builder.
62 engine_properties.dart_entrypoint_argv = nullptr;
63 engine_properties.dart_entrypoint_argc = 0;
64 }
65
66 return engine_properties;
67}
const std::wstring & GetIcuDataPath() const
const std::wstring & GetAssetsPath() const

◆ InitializeEngine()

EnginePtr flutter::testing::WindowsConfigBuilder::InitializeEngine ( ) const

Definition at line 69 of file windows_test_config_builder.cc.

69 {
71 return EnginePtr{FlutterDesktopEngineCreate(&engine_properties)};
72}
FlutterDesktopEngineProperties GetEngineProperties() const
std::unique_ptr< FlutterDesktopEngine, EngineDeleter > EnginePtr
FlutterDesktopEngineRef FlutterDesktopEngineCreate(const FlutterDesktopEngineProperties *engine_properties)

◆ Run()

ViewControllerPtr flutter::testing::WindowsConfigBuilder::Run ( ) const

Definition at line 95 of file windows_test_config_builder.cc.

95 {
96 InitializeCOM();
97
99 if (!engine) {
100 return {};
101 }
102
103 // Register native functions.
104 FlutterWindowsEngine* windows_engine =
105 reinterpret_cast<FlutterWindowsEngine*>(engine.get());
106 windows_engine->SetRootIsolateCreateCallback(
107 context_.GetRootIsolateCallback());
108
109 int width = 600;
110 int height = 400;
111
112 // Create a view controller that owns the engine.
113 ViewControllerPtr controller{
115 if (!controller) {
116 return {};
117 }
118
119 return controller;
120}
FlutterEngine engine
Definition: main.cc:68
std::unique_ptr< FlutterDesktopViewController, ViewControllerDeleter > ViewControllerPtr
int32_t height
int32_t width
FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate(int width, int height, FlutterDesktopEngineRef engine)

◆ RunHeadless()

EnginePtr flutter::testing::WindowsConfigBuilder::RunHeadless ( ) const

Definition at line 74 of file windows_test_config_builder.cc.

74 {
75 InitializeCOM();
76
78 if (!engine) {
79 return {};
80 }
81
82 // Register native functions.
83 FlutterWindowsEngine* windows_engine =
84 reinterpret_cast<FlutterWindowsEngine*>(engine.get());
85 windows_engine->SetRootIsolateCreateCallback(
86 context_.GetRootIsolateCallback());
87
88 if (!FlutterDesktopEngineRun(engine.get(), /* entry_point */ nullptr)) {
89 return {};
90 }
91
92 return engine;
93}
bool FlutterDesktopEngineRun(FlutterDesktopEngineRef engine, const char *entry_point)

◆ SetDartEntrypoint()

void flutter::testing::WindowsConfigBuilder::SetDartEntrypoint ( std::string_view  entrypoint)

Definition at line 26 of file windows_test_config_builder.cc.

26 {
27 if (entrypoint.empty()) {
28 return;
29 }
30 dart_entrypoint_ = entrypoint;
31}

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