Flutter Engine
 
Loading...
Searching...
No Matches
vsync_waiter_unittests.cc
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#define FML_USED_ON_EMBEDDER
5
6#include <initializer_list>
7
11
12#include "gtest/gtest.h"
13#include "thread_host.h"
14#include "vsync_waiter.h"
15
16namespace flutter {
17namespace testing {
18
20 public:
21 explicit TestVsyncWaiter(const TaskRunners& task_runners)
22 : VsyncWaiter(task_runners) {}
23
25
26 protected:
27 void AwaitVSync() override { await_vsync_call_count_++; }
28};
29
30TEST(VsyncWaiterTest, NoUnneededAwaitVsync) {
32 std::string prefix = "vsync_waiter_test";
33
35 auto task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
36
37 const flutter::TaskRunners task_runners(prefix, task_runner, task_runner,
38 task_runner, task_runner);
39
40 TestVsyncWaiter vsync_waiter(task_runners);
41
42 vsync_waiter.ScheduleSecondaryCallback(1, [] {});
43 EXPECT_EQ(vsync_waiter.await_vsync_call_count_, 1);
44
45 vsync_waiter.ScheduleSecondaryCallback(2, [] {});
46 EXPECT_EQ(vsync_waiter.await_vsync_call_count_, 1);
47}
48
49} // namespace testing
50} // namespace flutter
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()
TEST(NativeAssetsManagerTest, NoAvailableAssets)
The collection of all the threads used by the engine.
Definition thread_host.h:21