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

#include <vsync_waiters_test.h>

Inheritance diagram for flutter::testing::ShellTestVsyncWaiter:
flutter::VsyncWaiter

Public Member Functions

 ShellTestVsyncWaiter (const TaskRunners &task_runners, std::shared_ptr< ShellTestVsyncClock > clock)
 
- Public Member Functions inherited from flutter::VsyncWaiter
virtual ~VsyncWaiter ()
 
void AsyncWaitForVsync (const Callback &callback)
 
void ScheduleSecondaryCallback (uintptr_t id, const fml::closure &callback)
 

Protected Member Functions

void AwaitVSync () override
 
- Protected Member Functions inherited from flutter::VsyncWaiter
 VsyncWaiter (const TaskRunners &task_runners)
 
virtual void AwaitVSync ()=0
 
virtual void AwaitVSyncForSecondaryCallback ()
 
void FireCallback (fml::TimePoint frame_start_time, fml::TimePoint frame_target_time, bool pause_secondary_tasks=true)
 

Additional Inherited Members

- Public Types inherited from flutter::VsyncWaiter
using Callback = std::function< void(std::unique_ptr< FrameTimingsRecorder >)>
 
- Protected Attributes inherited from flutter::VsyncWaiter
const TaskRunners task_runners_
 

Detailed Description

Definition at line 33 of file vsync_waiters_test.h.

Constructor & Destructor Documentation

◆ ShellTestVsyncWaiter()

flutter::testing::ShellTestVsyncWaiter::ShellTestVsyncWaiter ( const TaskRunners task_runners,
std::shared_ptr< ShellTestVsyncClock clock 
)
inline

Definition at line 35 of file vsync_waiters_test.h.

37 : VsyncWaiter(task_runners), clock_(std::move(clock)) {}
VsyncWaiter(const TaskRunners &task_runners)
Definition: vsync_waiter.cc:21

Member Function Documentation

◆ AwaitVSync()

void flutter::testing::ShellTestVsyncWaiter::AwaitVSync ( )
overrideprotectedvirtual

Implements flutter::VsyncWaiter.

Definition at line 35 of file vsync_waiters_test.cc.

35 {
37 auto vsync_future = clock_->NextVSync();
38
39 auto async_wait = std::async([&vsync_future, this]() {
40 vsync_future.wait();
41
42 // Post the `FireCallback` to the Platform thread so earlier Platform tasks
43 // (specifically, the `VSyncFlush` call) will be finished before
44 // `FireCallback` is executed. This is only needed for our unit tests.
45 //
46 // Without this, the repeated VSYNC signals in `VSyncFlush` may start both
47 // the current frame in the UI thread and the next frame in the secondary
48 // callback (both of them are waiting for VSYNCs). That breaks the unit
49 // test's assumption that each frame's VSYNC must be issued by different
50 // `VSyncFlush` call (which resets the `will_draw_new_frame` bit).
51 //
52 // For example, HandlesActualIphoneXsInputEvents will fail without this.
53 task_runners_.GetPlatformTaskRunner()->PostTask([this]() {
55 });
56 });
57}
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
Definition: task_runners.cc:34
fml::RefPtr< fml::TaskRunner > GetPlatformTaskRunner() const
Definition: task_runners.cc:30
void FireCallback(fml::TimePoint frame_start_time, fml::TimePoint frame_target_time, bool pause_secondary_tasks=true)
Definition: vsync_waiter.cc:87
const TaskRunners task_runners_
Definition: vsync_waiter.h:44
virtual bool RunsTasksOnCurrentThread()
Definition: task_runner.cc:43
static TimePoint Now()
Definition: time_point.cc:49
#define FML_DCHECK(condition)
Definition: logging.h:103

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