Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
vsync_waiter_unittests.cc
Go to the documentation of this file.
1#define FML_USED_ON_EMBEDDER
2
3#include <initializer_list>
4
5#include "flutter/common/settings.h"
6#include "flutter/common/task_runners.h"
7#include "flutter/shell/common/switches.h"
8
9#include "gtest/gtest.h"
10#include "thread_host.h"
11#include "vsync_waiter.h"
12
13namespace flutter {
14namespace testing {
15
17 public:
18 explicit TestVsyncWaiter(const TaskRunners& task_runners)
19 : VsyncWaiter(task_runners) {}
20
22
23 protected:
24 void AwaitVSync() override { await_vsync_call_count_++; }
25};
26
27TEST(VsyncWaiterTest, NoUnneededAwaitVsync) {
29 std::string prefix = "vsync_waiter_test";
30
32 auto task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
33
34 const flutter::TaskRunners task_runners(prefix, task_runner, task_runner,
35 task_runner, task_runner);
36
37 TestVsyncWaiter vsync_waiter(task_runners);
38
39 vsync_waiter.ScheduleSecondaryCallback(1, [] {});
40 EXPECT_EQ(vsync_waiter.await_vsync_call_count_, 1);
41
42 vsync_waiter.ScheduleSecondaryCallback(2, [] {});
43 EXPECT_EQ(vsync_waiter.await_vsync_call_count_, 1);
44}
45
46} // namespace testing
47} // namespace flutter
#define TEST(S, s, D, expected)
void ScheduleSecondaryCallback(uintptr_t id, const fml::closure &callback)
TestVsyncWaiter(const TaskRunners &task_runners)
static void EnsureInitializedForCurrentThread()
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
The collection of all the threads used by the engine.
Definition thread_host.h:21