forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvsync_waiter_unittests.cc
47 lines (33 loc) · 1.24 KB
/
vsync_waiter_unittests.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#define FML_USED_ON_EMBEDDER
#include <initializer_list>
#include "flutter/common/settings.h"
#include "flutter/common/task_runners.h"
#include "flutter/shell/common/switches.h"
#include "gtest/gtest.h"
#include "thread_host.h"
#include "vsync_waiter.h"
namespace flutter {
namespace testing {
class TestVsyncWaiter : public VsyncWaiter {
public:
explicit TestVsyncWaiter(const TaskRunners& task_runners)
: VsyncWaiter(task_runners) {}
int await_vsync_call_count_ = 0;
protected:
void AwaitVSync() override { await_vsync_call_count_++; }
};
TEST(VsyncWaiterTest, NoUnneededAwaitVsync) {
using flutter::ThreadHost;
std::string prefix = "vsync_waiter_test";
fml::MessageLoop::EnsureInitializedForCurrentThread();
auto task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
const flutter::TaskRunners task_runners(prefix, task_runner, task_runner,
task_runner, task_runner);
TestVsyncWaiter vsync_waiter(task_runners);
vsync_waiter.ScheduleSecondaryCallback(1, [] {});
EXPECT_EQ(vsync_waiter.await_vsync_call_count_, 1);
vsync_waiter.ScheduleSecondaryCallback(2, [] {});
EXPECT_EQ(vsync_waiter.await_vsync_call_count_, 1);
}
} // namespace testing
} // namespace flutter