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

#include <shell_test.h>

Inheritance diagram for flutter::testing::ShellTest:
flutter::testing::FixtureTest flutter::testing::DartFixture flutter::testing::ThreadTest flutter::testing::FuchsiaShellTest flutter::testing::ImageDisposeTest flutter::testing::PlatformConfigurationTest

Classes

struct  Config
 

Public Types

enum  ServiceProtocolEnum {
  kGetSkSLs ,
  kEstimateRasterCacheMemory ,
  kSetAssetBundlePath ,
  kRunInView
}
 

Public Member Functions

 ShellTest ()
 
Settings CreateSettingsForFixture () override
 
std::unique_ptr< ShellCreateShell (const Settings &settings, std::optional< TaskRunners > task_runners={})
 
std::unique_ptr< ShellCreateShell (const Config &config)
 
void DestroyShell (std::unique_ptr< Shell > shell)
 
void DestroyShell (std::unique_ptr< Shell > shell, const TaskRunners &task_runners)
 
TaskRunners GetTaskRunnersForFixture ()
 
fml::TimePoint GetLatestFrameTargetTime (Shell *shell) const
 
void SendPlatformMessage (Shell *shell, std::unique_ptr< PlatformMessage > message)
 
void SendSemanticsAction (Shell *shell, int64_t view_id, int32_t node_id, SemanticsAction action, fml::MallocMapping args)
 
void SendEnginePlatformMessage (Shell *shell, std::unique_ptr< PlatformMessage > message)
 
std::shared_ptr< txt::FontCollectionGetFontCollection (Shell *shell)
 
- 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)
 
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.
 
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.
 

Static Public Member Functions

static void PlatformViewNotifyCreated (Shell *shell)
 
static void PlatformViewNotifyDestroyed (Shell *shell)
 
static void RunEngine (Shell *shell, RunConfiguration configuration)
 
static void RestartEngine (Shell *shell, RunConfiguration configuration)
 
static void VSyncFlush (Shell *shell, bool *will_draw_new_frame=nullptr)
 
static void SetViewportMetrics (Shell *shell, double width, double height)
 
static void NotifyIdle (Shell *shell, fml::TimeDelta deadline)
 
static void PumpOneFrame (Shell *shell)
 
static void PumpOneFrame (Shell *shell, FrameContent frame_content)
 
static void DispatchFakePointerData (Shell *shell, double x)
 
static void DispatchPointerData (Shell *shell, std::unique_ptr< PointerDataPacket > packet)
 
static bool GetNeedsReportTimings (Shell *shell)
 
static void SetNeedsReportTimings (Shell *shell, bool value)
 
static void StorePersistentCache (PersistentCache *cache, const SkData &key, const SkData &value)
 
static bool IsAnimatorRunning (Shell *shell)
 
static void OnServiceProtocol (Shell *shell, ServiceProtocolEnum some_protocol, const fml::RefPtr< fml::TaskRunner > &task_runner, const ServiceProtocol::Handler::ServiceProtocolMap &params, rapidjson::Document *response)
 
static int UnreportedTimingsCount (Shell *shell)
 
static void TurnOffGPU (Shell *shell, bool value)
 
static bool ShouldDiscardLayerTree (Shell *shell, int64_t view_id, const flutter::LayerTree &tree)
 

Additional Inherited Members

- Protected Member Functions inherited from flutter::testing::DartFixture
void SetSnapshotsAndAssets (Settings &settings)
 
- 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 63 of file shell_test.h.

Member Enumeration Documentation

◆ ServiceProtocolEnum

Enumerator
kGetSkSLs 
kEstimateRasterCacheMemory 
kSetAssetBundlePath 
kRunInView 

Definition at line 140 of file shell_test.h.

Constructor & Destructor Documentation

◆ ShellTest()

flutter::testing::ShellTest::ShellTest ( )

Definition at line 58 of file shell_test.cc.

59 : thread_host_("io.flutter.test." + GetCurrentTestName() + ".",
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:14

Member Function Documentation

◆ CreateSettingsForFixture()

Settings flutter::testing::ShellTest::CreateSettingsForFixture ( )
overridevirtual

Reimplemented from flutter::testing::DartFixture.

Definition at line 345 of file shell_test.cc.

345 {
346 Settings settings;
347 settings.leak_vm = false;
348 settings.task_observer_add = [](intptr_t key, const fml::closure& handler) {
351 handler);
352 return queue_id;
353 };
354 settings.task_observer_remove = [](fml::TaskQueueId queue_id, intptr_t key) {
356 key);
357 };
358 settings.isolate_create_callback = [this]() {
359 native_resolver_->SetNativeResolverForIsolate();
360 };
361#if OS_FUCHSIA
362 settings.verbose_logging = true;
363#endif
364 SetSnapshotsAndAssets(settings);
365 return settings;
366}
void SetSnapshotsAndAssets(Settings &settings)
std::shared_ptr< TestDartNativeResolver > native_resolver_
static TaskQueueId GetCurrentTaskQueueId()
static MessageLoopTaskQueues * GetInstance()
void AddTaskObserver(TaskQueueId queue_id, intptr_t key, const fml::closure &callback)
void RemoveTaskObserver(TaskQueueId queue_id, intptr_t key)
const gchar FlBinaryMessengerMessageHandler handler
std::function< void()> closure
Definition closure.h:14

References fml::MessageLoopTaskQueues::AddTaskObserver(), fml::MessageLoop::GetCurrentTaskQueueId(), fml::MessageLoopTaskQueues::GetInstance(), handler, flutter::Settings::isolate_create_callback, key, flutter::Settings::leak_vm, fml::MessageLoopTaskQueues::RemoveTaskObserver(), flutter::Settings::task_observer_add, flutter::Settings::task_observer_remove, and flutter::Settings::verbose_logging.

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

◆ CreateShell() [1/2]

std::unique_ptr< Shell > flutter::testing::ShellTest::CreateShell ( const Config config)

Definition at line 391 of file shell_test.cc.

391 {
392 TaskRunners task_runners = config.task_runners.has_value()
393 ? config.task_runners.value()
395 Shell::CreateCallback<PlatformView> platform_view_create_callback =
396 config.platform_view_create_callback;
397 if (!platform_view_create_callback) {
398 platform_view_create_callback = ShellTestPlatformViewBuilder({});
399 }
400
401 Shell::CreateCallback<Rasterizer> rasterizer_create_callback =
402 [](Shell& shell) { return std::make_unique<Rasterizer>(shell); };
403
405 task_runners, //
406 config.settings, //
407 platform_view_create_callback, //
408 rasterizer_create_callback, //
409 config.is_gpu_disabled //
410 );
411}
static std::unique_ptr< Shell > Create(const PlatformData &platform_data, const TaskRunners &task_runners, Settings settings, const CreateCallback< PlatformView > &on_create_platform_view, const CreateCallback< Rasterizer > &on_create_rasterizer, bool is_gpu_disabled=false)
Creates a shell instance using the provided settings. The callbacks to create the various shell subco...
Definition shell.cc:221
TaskRunners GetTaskRunnersForFixture()

References flutter::testing::GetTaskRunnersForFixture(), flutter::testing::ShellTest::Config::is_gpu_disabled, flutter::testing::ShellTest::Config::platform_view_create_callback, flutter::testing::ShellTest::Config::settings, and flutter::testing::ShellTest::Config::task_runners.

◆ CreateShell() [2/2]

std::unique_ptr< Shell > flutter::testing::ShellTest::CreateShell ( const Settings settings,
std::optional< TaskRunners task_runners = {} 
)

Definition at line 382 of file shell_test.cc.

384 {
385 return CreateShell({
386 .settings = settings,
387 .task_runners = std::move(task_runners),
388 });
389}
std::unique_ptr< Shell > CreateShell(const Settings &settings, std::optional< TaskRunners > task_runners={})

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

◆ DestroyShell() [1/2]

void flutter::testing::ShellTest::DestroyShell ( std::unique_ptr< Shell shell)

Definition at line 413 of file shell_test.cc.

413 {
414 DestroyShell(std::move(shell), GetTaskRunnersForFixture());
415}
void DestroyShell(std::unique_ptr< Shell > shell)

References flutter::testing::GetTaskRunnersForFixture().

◆ DestroyShell() [2/2]

void flutter::testing::ShellTest::DestroyShell ( std::unique_ptr< Shell shell,
const TaskRunners task_runners 
)

Definition at line 417 of file shell_test.cc.

418 {
420 fml::TaskRunner::RunNowOrPostTask(task_runners.GetPlatformTaskRunner(),
421 [&shell, &latch]() mutable {
422 shell.reset();
423 latch.Signal();
424 });
425 latch.Wait();
426}
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)

References flutter::TaskRunners::GetPlatformTaskRunner(), fml::TaskRunner::RunNowOrPostTask(), and fml::AutoResetWaitableEvent::Wait().

◆ DispatchFakePointerData()

void flutter::testing::ShellTest::DispatchFakePointerData ( Shell shell,
double  x 
)
static

Definition at line 273 of file shell_test.cc.

273 {
274 auto packet = std::make_unique<PointerDataPacket>(1);
275 packet->SetPointerData(0, PointerData{
277 .physical_x = x,
278 });
279 DispatchPointerData(shell, std::move(packet));
280}
static void DispatchPointerData(Shell *shell, std::unique_ptr< PointerDataPacket > packet)
int32_t x

References flutter::PointerData::change, and x.

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

◆ DispatchPointerData()

void flutter::testing::ShellTest::DispatchPointerData ( Shell shell,
std::unique_ptr< PointerDataPacket packet 
)
static

Definition at line 282 of file shell_test.cc.

283 {
285 shell->GetTaskRunners().GetPlatformTaskRunner()->PostTask(
286 [&latch, shell, &packet]() {
287 // Goes through PlatformView to ensure packet is corrected converted.
288 shell->GetPlatformView()->DispatchPointerDataPacket(std::move(packet));
289 latch.Signal();
290 });
291 latch.Wait();
292}
static void DispatchPointerDataPacket(JNIEnv *env, jobject jcaller, jlong shell_holder, jobject buffer, jint position)

References flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetPlatformView(), flutter::Shell::GetTaskRunners(), fml::TaskRunner::PostTask(), fml::AutoResetWaitableEvent::Signal(), and fml::AutoResetWaitableEvent::Wait().

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

◆ GetFontCollection()

std::shared_ptr< txt::FontCollection > flutter::testing::ShellTest::GetFontCollection ( Shell shell)

Definition at line 340 of file shell_test.cc.

341 {
342 return shell->weak_engine_->GetFontCollection().GetFontCollection();
343}

◆ GetLatestFrameTargetTime()

fml::TimePoint flutter::testing::ShellTest::GetLatestFrameTargetTime ( Shell shell) const

Definition at line 378 of file shell_test.cc.

378 {
379 return shell->GetLatestFrameTargetTime();
380}

◆ GetNeedsReportTimings()

bool flutter::testing::ShellTest::GetNeedsReportTimings ( Shell shell)
static

Definition at line 302 of file shell_test.cc.

302 {
303 return shell->needs_report_timings_;
304}

◆ GetTaskRunnersForFixture()

TaskRunners flutter::testing::ShellTest::GetTaskRunnersForFixture ( )

Definition at line 368 of file shell_test.cc.

368 {
369 return {
370 "test",
371 thread_host_.platform_thread->GetTaskRunner(), // platform
372 thread_host_.raster_thread->GetTaskRunner(), // raster
373 thread_host_.ui_thread->GetTaskRunner(), // ui
374 thread_host_.io_thread->GetTaskRunner() // io
375 };
376}
std::unique_ptr< fml::Thread > io_thread
Definition thread_host.h:86
std::unique_ptr< fml::Thread > platform_thread
Definition thread_host.h:83
std::unique_ptr< fml::Thread > raster_thread
Definition thread_host.h:85
std::unique_ptr< fml::Thread > ui_thread
Definition thread_host.h:84

References thread_host_.

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

◆ IsAnimatorRunning()

static bool flutter::testing::ShellTest::IsAnimatorRunning ( Shell shell)
static

◆ NotifyIdle()

void flutter::testing::ShellTest::NotifyIdle ( Shell shell,
fml::TimeDelta  deadline 
)
static

Definition at line 212 of file shell_test.cc.

212 {
214 shell->GetTaskRunners().GetUITaskRunner()->PostTask(
215 [&latch, engine = shell->weak_engine_, deadline]() {
216 if (engine) {
217 engine->NotifyIdle(deadline);
218 }
219 latch.Signal();
220 });
221 latch.Wait();
222}
FlutterEngine engine
Definition main.cc:84

References engine, flutter::Shell::GetTaskRunners(), flutter::TaskRunners::GetUITaskRunner(), fml::TaskRunner::PostTask(), and fml::AutoResetWaitableEvent::Signal().

◆ OnServiceProtocol()

void flutter::testing::ShellTest::OnServiceProtocol ( Shell shell,
ServiceProtocolEnum  some_protocol,
const fml::RefPtr< fml::TaskRunner > &  task_runner,
const ServiceProtocol::Handler::ServiceProtocolMap params,
rapidjson::Document *  response 
)
static

Definition at line 312 of file shell_test.cc.

317 {
318 std::promise<bool> finished;
320 task_runner, [shell, some_protocol, params, response, &finished]() {
321 switch (some_protocol) {
323 shell->OnServiceProtocolGetSkSLs(params, response);
324 break;
326 shell->OnServiceProtocolEstimateRasterCacheMemory(params, response);
327 break;
329 shell->OnServiceProtocolSetAssetBundlePath(params, response);
330 break;
332 shell->OnServiceProtocolRunInView(params, response);
333 break;
334 }
335 finished.set_value(true);
336 });
337 finished.get_future().wait();
338}
const EmbeddedViewParams * params

References params, and fml::TaskRunner::RunNowOrPostTask().

◆ PlatformViewNotifyCreated()

void flutter::testing::ShellTest::PlatformViewNotifyCreated ( Shell shell)
static

Definition at line 93 of file shell_test.cc.

93 {
96 shell->GetTaskRunners().GetPlatformTaskRunner(), [shell, &latch]() {
97 shell->GetPlatformView()->NotifyCreated();
98 latch.Signal();
99 });
100 latch.Wait();
101}

References flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetTaskRunners(), fml::TaskRunner::RunNowOrPostTask(), and fml::AutoResetWaitableEvent::Wait().

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

◆ PlatformViewNotifyDestroyed()

void flutter::testing::ShellTest::PlatformViewNotifyDestroyed ( Shell shell)
static

Definition at line 103 of file shell_test.cc.

103 {
106 shell->GetTaskRunners().GetPlatformTaskRunner(), [shell, &latch]() {
107 shell->GetPlatformView()->NotifyDestroyed();
108 latch.Signal();
109 });
110 latch.Wait();
111}

References flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetTaskRunners(), fml::TaskRunner::RunNowOrPostTask(), and fml::AutoResetWaitableEvent::Wait().

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

◆ PumpOneFrame() [1/2]

void flutter::testing::ShellTest::PumpOneFrame ( Shell shell)
static

Definition at line 224 of file shell_test.cc.

224 {
226}
static void PumpOneFrame(Shell *shell)
static FrameContent DummyView(double width=1, double height=1)
Definition shell_test.cc:29

◆ PumpOneFrame() [2/2]

void flutter::testing::ShellTest::PumpOneFrame ( Shell shell,
FrameContent  frame_content 
)
static

Definition at line 228 of file shell_test.cc.

228 {
229 // Set viewport to nonempty, and call Animator::BeginFrame to make the layer
230 // tree pipeline nonempty. Without either of this, the layer tree below
231 // won't be rasterized.
234 shell->weak_engine_;
235 shell->GetTaskRunners().GetUITaskRunner()->PostTask(
236 [&latch, engine = shell->weak_engine_, &frame_content,
237 runtime_delegate]() {
238 for (auto& [view_id, view_content] : frame_content) {
239 engine->SetViewportMetrics(view_id, view_content.viewport_metrics);
240 }
241 const auto frame_begin_time = fml::TimePoint::Now();
242 const auto frame_end_time =
243 frame_begin_time + fml::TimeDelta::FromSecondsF(1.0 / 60.0);
244 std::unique_ptr<FrameTimingsRecorder> recorder =
245 std::make_unique<FrameTimingsRecorder>();
246 recorder->RecordVsync(frame_begin_time, frame_end_time);
247 engine->animator_->BeginFrame(std::move(recorder));
248
249 // The BeginFrame phase and the EndFrame phase must be performed in a
250 // single task, otherwise a normal vsync might be inserted in between,
251 // causing flaky assertion errors.
252
253 for (auto& [view_id, view_content] : frame_content) {
254 auto root_layer = std::make_shared<TransformLayer>(DlMatrix());
255 auto layer_tree = std::make_unique<LayerTree>(
256 root_layer,
257 DlISize(view_content.viewport_metrics.physical_width,
258 view_content.viewport_metrics.physical_height));
259 float device_pixel_ratio = static_cast<float>(
260 view_content.viewport_metrics.device_pixel_ratio);
261 if (view_content.builder) {
262 view_content.builder(root_layer);
263 }
264 runtime_delegate->Render(view_id, std::move(layer_tree),
265 device_pixel_ratio);
266 }
267 engine->animator_->EndFrame();
268 latch.Signal();
269 });
270 latch.Wait();
271}
static constexpr TimeDelta FromSecondsF(double seconds)
Definition time_delta.h:53
static TimePoint Now()
Definition time_point.cc:49
G_BEGIN_DECLS FlutterViewId view_id
impeller::Matrix DlMatrix
impeller::ISize32 DlISize

References engine, fml::TimeDelta::FromSecondsF(), flutter::Shell::GetTaskRunners(), flutter::TaskRunners::GetUITaskRunner(), fml::TimePoint::Now(), fml::TaskRunner::PostTask(), fml::AutoResetWaitableEvent::Signal(), and view_id.

◆ RestartEngine()

void flutter::testing::ShellTest::RestartEngine ( Shell shell,
RunConfiguration  configuration 
)
static

Definition at line 127 of file shell_test.cc.

127 {
128 std::promise<bool> restarted;
130 shell->GetTaskRunners().GetUITaskRunner(),
131 [shell, &restarted, &configuration]() {
132 restarted.set_value(shell->engine_->Restart(std::move(configuration)));
133 });
134 ASSERT_TRUE(restarted.get_future().get());
135}

References flutter::Shell::GetTaskRunners(), flutter::TaskRunners::GetUITaskRunner(), and fml::TaskRunner::RunNowOrPostTask().

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

◆ RunEngine()

void flutter::testing::ShellTest::RunEngine ( Shell shell,
RunConfiguration  configuration 
)
static

Definition at line 113 of file shell_test.cc.

113 {
116 shell->GetTaskRunners().GetPlatformTaskRunner(),
117 [shell, &latch, &configuration]() {
118 shell->RunEngine(std::move(configuration),
119 [&latch](Engine::RunStatus run_status) {
120 ASSERT_EQ(run_status, Engine::RunStatus::Success);
121 latch.Signal();
122 });
123 });
124 latch.Wait();
125}

References flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetTaskRunners(), and fml::TaskRunner::RunNowOrPostTask().

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

◆ SendEnginePlatformMessage()

void flutter::testing::ShellTest::SendEnginePlatformMessage ( Shell shell,
std::unique_ptr< PlatformMessage message 
)

Definition at line 77 of file shell_test.cc.

79 {
82 shell->GetTaskRunners().GetPlatformTaskRunner(),
84 [shell, &latch, message = std::move(message)]() mutable {
85 if (auto engine = shell->weak_engine_) {
86 engine->HandlePlatformMessage(std::move(message));
87 }
88 latch.Signal();
89 }));
90 latch.Wait();
91}
G_BEGIN_DECLS GBytes * message
internal::CopyableLambda< T > MakeCopyable(T lambda)

References flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetTaskRunners(), fml::MakeCopyable(), message, fml::TaskRunner::RunNowOrPostTask(), and fml::AutoResetWaitableEvent::Signal().

◆ SendPlatformMessage()

void flutter::testing::ShellTest::SendPlatformMessage ( Shell shell,
std::unique_ptr< PlatformMessage message 
)

Definition at line 63 of file shell_test.cc.

64 {
65 shell->OnPlatformViewDispatchPlatformMessage(std::move(message));
66}

References message.

◆ SendSemanticsAction()

void flutter::testing::ShellTest::SendSemanticsAction ( Shell shell,
int64_t  view_id,
int32_t  node_id,
SemanticsAction  action,
fml::MallocMapping  args 
)

Definition at line 68 of file shell_test.cc.

72 {
73 shell->OnPlatformViewDispatchSemanticsAction(view_id, node_id, action,
74 std::move(args));
75}
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

References action, args, and view_id.

◆ SetNeedsReportTimings()

void flutter::testing::ShellTest::SetNeedsReportTimings ( Shell shell,
bool  value 
)
static

Definition at line 298 of file shell_test.cc.

298 {
299 shell->SetNeedsReportTimings(value);
300}

References value.

◆ SetViewportMetrics()

void flutter::testing::ShellTest::SetViewportMetrics ( Shell shell,
double  width,
double  height 
)
static

Definition at line 163 of file shell_test.cc.

163 {
164 flutter::ViewportMetrics viewport_metrics = {
165 1, // device pixel ratio
166 width, // physical width
167 height, // physical height
168 0, // min width constraint
169 0, // max width constraint
170 0, // min height constraint
171 0, // max height constraint
172 0, // padding top
173 0, // padding right
174 0, // padding bottom
175 0, // padding left
176 0, // view inset top
177 0, // view inset right
178 0, // view inset bottom
179 0, // view inset left
180 0, // gesture inset top
181 0, // gesture inset right
182 0, // gesture inset bottom
183 0, // gesture inset left
184 22, // physical touch slop
185 std::vector<double>(), // display features bounds
186 std::vector<int>(), // display features type
187 std::vector<int>(), // display features state
188 0 // Display ID
189 };
190 // Set viewport to nonempty, and call Animator::BeginFrame to make the layer
191 // tree pipeline nonempty. Without either of this, the layer tree below
192 // won't be rasterized.
194 shell->GetTaskRunners().GetUITaskRunner()->PostTask(
195 [&latch, engine = shell->weak_engine_, viewport_metrics]() {
196 if (engine) {
197 engine->SetViewportMetrics(kImplicitViewId, viewport_metrics);
198 const auto frame_begin_time = fml::TimePoint::Now();
199 const auto frame_end_time =
200 frame_begin_time + fml::TimeDelta::FromSecondsF(1.0 / 60.0);
201 std::unique_ptr<FrameTimingsRecorder> recorder =
202 std::make_unique<FrameTimingsRecorder>();
203 recorder->RecordVsync(frame_begin_time, frame_end_time);
204 engine->animator_->BeginFrame(std::move(recorder));
205 engine->animator_->EndFrame();
206 }
207 latch.Signal();
208 });
209 latch.Wait();
210}
int32_t height
int32_t width

References engine, flutter::Shell::GetTaskRunners(), flutter::TaskRunners::GetUITaskRunner(), height, fml::TaskRunner::PostTask(), fml::AutoResetWaitableEvent::Signal(), and width.

◆ ShouldDiscardLayerTree()

bool flutter::testing::ShellTest::ShouldDiscardLayerTree ( Shell shell,
int64_t  view_id,
const flutter::LayerTree tree 
)
static

Definition at line 432 of file shell_test.cc.

434 {
435 return shell->ShouldDiscardLayerTree(view_id, tree);
436}

References view_id.

◆ StorePersistentCache()

void flutter::testing::ShellTest::StorePersistentCache ( PersistentCache cache,
const SkData &  key,
const SkData &  value 
)
static

Definition at line 306 of file shell_test.cc.

308 {
309 cache->store(key, value);
310}

References key, and value.

◆ TurnOffGPU()

void flutter::testing::ShellTest::TurnOffGPU ( Shell shell,
bool  value 
)
static

Definition at line 428 of file shell_test.cc.

428 {
429 shell->is_gpu_disabled_sync_switch_->SetSwitch(value);
430}

References value.

◆ UnreportedTimingsCount()

int flutter::testing::ShellTest::UnreportedTimingsCount ( Shell shell)
static

Definition at line 294 of file shell_test.cc.

294 {
295 return shell->unreported_timings_.size();
296}

◆ VSyncFlush()

void flutter::testing::ShellTest::VSyncFlush ( Shell shell,
bool *  will_draw_new_frame = nullptr 
)
static

Issue as many VSYNC as needed to flush the UI tasks so far, and reset the content of will_draw_new_frame to true if it's not nullptr.

Definition at line 137 of file shell_test.cc.

137 {
140 shell->GetTaskRunners().GetPlatformTaskRunner(),
141 [shell, will_draw_new_frame, &latch] {
142 // The following UI task ensures that all previous UI tasks are flushed.
143 fml::AutoResetWaitableEvent ui_latch;
144 shell->GetTaskRunners().GetUITaskRunner()->PostTask(
145 [&ui_latch, will_draw_new_frame]() {
146 if (will_draw_new_frame != nullptr) {
147 *will_draw_new_frame = true;
148 }
149 ui_latch.Signal();
150 });
151
152 ShellTestPlatformView* test_platform_view =
153 static_cast<ShellTestPlatformView*>(shell->GetPlatformView().get());
154 do {
155 test_platform_view->SimulateVSync();
156 } while (ui_latch.WaitWithTimeout(fml::TimeDelta::FromMilliseconds(1)));
157
158 latch.Signal();
159 });
160 latch.Wait();
161}
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition time_delta.h:46

References fml::TimeDelta::FromMilliseconds(), flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetPlatformView(), flutter::Shell::GetTaskRunners(), fml::TaskRunner::RunNowOrPostTask(), fml::AutoResetWaitableEvent::Signal(), and flutter::testing::ShellTestPlatformView::SimulateVSync().

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


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