Flutter Engine
flutter::testing::ShellTestVsyncWaiter Class Reference

#include <vsync_waiters_test.h>

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

Public Member Functions

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

Protected Member Functions

void AwaitVSync () override
 
- Protected Member Functions inherited from flutter::VsyncWaiter
 VsyncWaiter (TaskRunners task_runners)
 
void FireCallback (fml::TimePoint frame_start_time, fml::TimePoint frame_target_time)
 

Additional Inherited Members

- Public Types inherited from flutter::VsyncWaiter
using Callback = std::function< void(fml::TimePoint frame_start_time, fml::TimePoint frame_target_time)>
 
- Protected Attributes inherited from flutter::VsyncWaiter
const TaskRunners task_runners_
 

Detailed Description

Definition at line 31 of file vsync_waiters_test.h.

Constructor & Destructor Documentation

◆ ShellTestVsyncWaiter()

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

Definition at line 33 of file vsync_waiters_test.h.

35  : VsyncWaiter(std::move(task_runners)), clock_(clock) {}
VsyncWaiter(TaskRunners task_runners)
Definition: vsync_waiter.cc:32

Member Function Documentation

◆ AwaitVSync()

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

Implements flutter::VsyncWaiter.

Definition at line 35 of file vsync_waiters_test.cc.

References FML_DCHECK, fml::TimePoint::Now(), and task_runners_.

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.
55  });
56  });
57 }
#define FML_DCHECK(condition)
Definition: logging.h:86
fml::RefPtr< fml::TaskRunner > GetPlatformTaskRunner() const
Definition: task_runners.cc:30
virtual void PostTask(const fml::closure &task)
Definition: task_runner.cc:24
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
Definition: task_runners.cc:34
void FireCallback(fml::TimePoint frame_start_time, fml::TimePoint frame_target_time)
Definition: vsync_waiter.cc:91
const TaskRunners task_runners_
Definition: vsync_waiter.h:39
virtual bool RunsTasksOnCurrentThread()
Definition: task_runner.cc:43
static TimePoint Now()
Definition: time_point.cc:26

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