Flutter Engine
The Flutter Engine
vsync_waiters_test.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_COMMON_VSYNC_WAITERS_TEST_H_
6#define FLUTTER_SHELL_COMMON_VSYNC_WAITERS_TEST_H_
7
8#define FML_USED_ON_EMBEDDER
9
10#include <utility>
11
12#include "flutter/shell/common/shell.h"
13
14namespace flutter {
15namespace testing {
16
17using CreateVsyncWaiter = std::function<std::unique_ptr<VsyncWaiter>()>;
18
20 public:
21 /// Simulate that a vsync signal is triggered.
22 void SimulateVSync();
23
24 /// A future that will return the index the next vsync signal.
25 std::future<int> NextVSync();
26
27 private:
28 std::mutex mutex_;
29 std::vector<std::promise<int>> vsync_promised_;
30 size_t vsync_issued_ = 0;
31};
32
34 public:
35 ShellTestVsyncWaiter(const TaskRunners& task_runners,
36 std::shared_ptr<ShellTestVsyncClock> clock)
37 : VsyncWaiter(task_runners), clock_(std::move(clock)) {}
38
39 protected:
40 void AwaitVSync() override;
41
42 private:
43 std::shared_ptr<ShellTestVsyncClock> clock_;
44};
45
47 public:
48 // both of these are set in the past so as to fire immediately.
53
54 explicit ConstantFiringVsyncWaiter(const TaskRunners& task_runners)
55 : VsyncWaiter(task_runners) {}
56
57 protected:
58 void AwaitVSync() override;
59};
60
62 public:
63 explicit TestRefreshRateReporter(double refresh_rate);
64 void UpdateRefreshRate(double refresh_rate);
65
66 // |RefreshRateReporter|
67 double GetRefreshRate() const override;
68
69 private:
70 double refresh_rate_;
71};
72
73} // namespace testing
74} // namespace flutter
75
76#endif // FLUTTER_SHELL_COMMON_VSYNC_WAITERS_TEST_H_
static constexpr fml::TimePoint kFrameTargetTime
static constexpr fml::TimePoint kFrameBeginTime
ConstantFiringVsyncWaiter(const TaskRunners &task_runners)
std::future< int > NextVSync()
A future that will return the index the next vsync signal.
void SimulateVSync()
Simulate that a vsync signal is triggered.
ShellTestVsyncWaiter(const TaskRunners &task_runners, std::shared_ptr< ShellTestVsyncClock > clock)
static constexpr TimeDelta FromSeconds(int64_t seconds)
Definition: time_delta.h:49
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
Definition: time_point.h:43
std::function< std::unique_ptr< VsyncWaiter >()> CreateVsyncWaiter
Definition: ref_ptr.h:256