Flutter Engine
 
Loading...
Searching...
No Matches
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 SetUIThreadPolicy (FlutterDesktopUIThreadPolicy policy)
 
void AddDartEntrypointArgument (std::string_view arg)
 
void SetGpuPreference (FlutterDesktopGpuPreference gpu_preference)
 
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 38 of file windows_test_config_builder.cc.

38 {
39 if (arg.empty()) {
40 return;
41 }
42
43 dart_entrypoint_arguments_.emplace_back(std::move(arg));
44}

◆ GetEngineProperties()

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

Definition at line 51 of file windows_test_config_builder.cc.

52 {
53 FlutterDesktopEngineProperties engine_properties = {};
54 engine_properties.assets_path = context_.GetAssetsPath().c_str();
55 engine_properties.icu_data_path = context_.GetIcuDataPath().c_str();
56
57 // Set Dart entrypoint.
58 engine_properties.dart_entrypoint = dart_entrypoint_.c_str();
59
60 // Set Dart entrypoint argc, argv.
61 std::vector<const char*> dart_args;
62 dart_args.reserve(dart_entrypoint_arguments_.size());
63 for (const auto& arg : dart_entrypoint_arguments_) {
64 dart_args.push_back(arg.c_str());
65 }
66 if (!dart_args.empty()) {
67 engine_properties.dart_entrypoint_argv = dart_args.data();
68 engine_properties.dart_entrypoint_argc = dart_args.size();
69 } else {
70 // Clear this out in case this is not the first engine launch from the
71 // embedder config builder.
72 engine_properties.dart_entrypoint_argv = nullptr;
73 engine_properties.dart_entrypoint_argc = 0;
74 }
75
76 engine_properties.gpu_preference = gpu_preference_;
77 engine_properties.ui_thread_policy = ui_thread_policy_;
78
79 return engine_properties;
80}
const std::wstring & GetIcuDataPath() const
const std::wstring & GetAssetsPath() const
FlutterDesktopUIThreadPolicy ui_thread_policy
FlutterDesktopGpuPreference gpu_preference

References FlutterDesktopEngineProperties::assets_path, FlutterDesktopEngineProperties::dart_entrypoint, FlutterDesktopEngineProperties::dart_entrypoint_argc, FlutterDesktopEngineProperties::dart_entrypoint_argv, flutter::testing::WindowsTestContext::GetAssetsPath(), flutter::testing::WindowsTestContext::GetIcuDataPath(), FlutterDesktopEngineProperties::gpu_preference, FlutterDesktopEngineProperties::icu_data_path, and FlutterDesktopEngineProperties::ui_thread_policy.

Referenced by InitializeEngine().

◆ InitializeEngine()

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

Definition at line 82 of file windows_test_config_builder.cc.

82 {
84 return EnginePtr{FlutterDesktopEngineCreate(&engine_properties)};
85}
FlutterDesktopEngineProperties GetEngineProperties() const
std::unique_ptr< FlutterDesktopEngine, EngineDeleter > EnginePtr
FlutterDesktopEngineRef FlutterDesktopEngineCreate(const FlutterDesktopEngineProperties *engine_properties)

References FlutterDesktopEngineCreate(), and GetEngineProperties().

Referenced by Run(), RunHeadless(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ Run()

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

Definition at line 108 of file windows_test_config_builder.cc.

108 {
109 InitializeCOM();
110
112 if (!engine) {
113 return {};
114 }
115
116 // Register native functions.
117 FlutterWindowsEngine* windows_engine =
118 reinterpret_cast<FlutterWindowsEngine*>(engine.get());
119 windows_engine->SetRootIsolateCreateCallback(
120 context_.GetRootIsolateCallback());
121
122 int width = 600;
123 int height = 400;
124
125 // Create a view controller that owns the engine.
126 ViewControllerPtr controller{
128 if (!controller) {
129 return {};
130 }
131
132 return controller;
133}
FlutterEngine engine
Definition main.cc:84
std::unique_ptr< FlutterDesktopViewController, ViewControllerDeleter > ViewControllerPtr
int32_t height
int32_t width
FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate(int width, int height, FlutterDesktopEngineRef engine)

References engine, FlutterDesktopViewControllerCreate(), flutter::testing::WindowsTestContext::GetRootIsolateCallback(), height, InitializeEngine(), flutter::FlutterWindowsEngine::SetRootIsolateCreateCallback(), and width.

Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ RunHeadless()

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

Definition at line 87 of file windows_test_config_builder.cc.

87 {
88 InitializeCOM();
89
91 if (!engine) {
92 return {};
93 }
94
95 // Register native functions.
96 FlutterWindowsEngine* windows_engine =
97 reinterpret_cast<FlutterWindowsEngine*>(engine.get());
98 windows_engine->SetRootIsolateCreateCallback(
99 context_.GetRootIsolateCallback());
100
101 if (!FlutterDesktopEngineRun(engine.get(), /* entry_point */ nullptr)) {
102 return {};
103 }
104
105 return engine;
106}
bool FlutterDesktopEngineRun(FlutterDesktopEngineRef engine, const char *entry_point)

References engine, FlutterDesktopEngineRun(), flutter::testing::WindowsTestContext::GetRootIsolateCallback(), InitializeEngine(), and flutter::FlutterWindowsEngine::SetRootIsolateCreateCallback().

Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ SetDartEntrypoint()

◆ SetGpuPreference()

void flutter::testing::WindowsConfigBuilder::SetGpuPreference ( FlutterDesktopGpuPreference  gpu_preference)

Definition at line 46 of file windows_test_config_builder.cc.

47 {
48 gpu_preference_ = gpu_preference;
49}

Referenced by flutter::testing::TEST_F().

◆ SetUIThreadPolicy()

void flutter::testing::WindowsConfigBuilder::SetUIThreadPolicy ( FlutterDesktopUIThreadPolicy  policy)

Definition at line 33 of file windows_test_config_builder.cc.

34 {
35 ui_thread_policy_ = policy;
36}
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network policy

References flutter::policy.


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