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 #define FML_USED_ON_EMBEDDER
6 
7 #ifndef FLUTTER_SHELL_COMMON_VSYNC_WAITERS_TEST_H_
8 #define FLUTTER_SHELL_COMMON_VSYNC_WAITERS_TEST_H_
9 
10 #include "flutter/shell/common/shell.h"
11 
12 namespace flutter {
13 namespace testing {
14 
15 using CreateVsyncWaiter = std::function<std::unique_ptr<VsyncWaiter>()>;
16 
18  public:
19  /// Simulate that a vsync signal is triggered.
20  void SimulateVSync();
21 
22  /// A future that will return the index the next vsync signal.
23  std::future<int> NextVSync();
24 
25  private:
26  std::mutex mutex_;
27  std::vector<std::promise<int>> vsync_promised_;
28  size_t vsync_issued_ = 0;
29 };
30 
32  public:
34  std::shared_ptr<ShellTestVsyncClock> clock)
35  : VsyncWaiter(std::move(task_runners)), clock_(clock) {}
36 
37  protected:
38  void AwaitVSync() override;
39 
40  private:
41  std::shared_ptr<ShellTestVsyncClock> clock_;
42 };
43 
45  public:
46  // both of these are set in the past so as to fire immediately.
47  static constexpr fml::TimePoint frame_begin_time =
49  static constexpr fml::TimePoint frame_target_time =
51 
53  : VsyncWaiter(std::move(task_runners)) {}
54 
55  protected:
56  void AwaitVSync() override;
57 };
58 
59 } // namespace testing
60 } // namespace flutter
61 
62 #endif // FLUTTER_SHELL_COMMON_VSYNC_WAITERS_TEST_H_
void SimulateVSync()
Simulate that a vsync signal is triggered.
static constexpr TimeDelta FromSeconds(int64_t seconds)
Definition: time_delta.h:49
Definition: ref_ptr.h:252
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
Definition: time_point.h:36
std::function< std::unique_ptr< VsyncWaiter >()> CreateVsyncWaiter
ConstantFiringVsyncWaiter(TaskRunners task_runners)
ShellTestVsyncWaiter(TaskRunners task_runners, std::shared_ptr< ShellTestVsyncClock > clock)
std::future< int > NextVSync()
A future that will return the index the next vsync signal.