Flutter Engine
flutter::testing::ShellTestVsyncWaiter Class Reference

#include <vsync_waiters_test.h>

Inheritance diagram for flutter::testing::ShellTestVsyncWaiter:

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 (uintptr_t id, const fml::closure &callback)

Protected Member Functions

void AwaitVSync () override
- Protected Member Functions inherited from flutter::VsyncWaiter
 VsyncWaiter (TaskRunners task_runners)
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 31 of file vsync_waiters_test.h.

Constructor & Destructor Documentation

◆ ShellTestVsyncWaiter()

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

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:37

Member Function Documentation

◆ AwaitVSync()

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

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();
39  auto async_wait = std::async([&vsync_future, this]() {
40  vsync_future.wait();
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
void FireCallback(fml::TimePoint frame_start_time, fml::TimePoint frame_target_time, bool pause_secondary_tasks=true)
Definition: vsync_waiter.cc:97
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
Definition: task_runners.cc:34
const TaskRunners task_runners_
Definition: vsync_waiter.h:41
virtual bool RunsTasksOnCurrentThread()
Definition: task_runner.cc:43
virtual void PostTask(const fml::closure &task) override
Definition: task_runner.cc:24
static TimePoint Now()
Definition: time_point.cc:39

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