forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instrumentation_unittests.cc
46 lines (38 loc) · 1.58 KB
/
instrumentation_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
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/flow/instrumentation.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
using testing::Return;
namespace flutter {
namespace testing {
class MockRefreshRateUpdater : public Stopwatch::RefreshRateUpdater {
public:
MOCK_CONST_METHOD0(GetFrameBudget, fml::Milliseconds());
};
TEST(Instrumentation, GetDefaultFrameBudgetTest) {
fml::Milliseconds frame_budget_60fps = fml::RefreshRateToFrameBudget(60);
// The default constructor sets the frame_budget to 16.6667 (60 fps).
FixedRefreshRateStopwatch stopwatch;
fml::Milliseconds actual_frame_budget = stopwatch.GetFrameBudget();
EXPECT_EQ(frame_budget_60fps, actual_frame_budget);
}
TEST(Instrumentation, GetOneShotFrameBudgetTest) {
fml::Milliseconds frame_budget_90fps = fml::RefreshRateToFrameBudget(90);
FixedRefreshRateStopwatch stopwatch(frame_budget_90fps);
fml::Milliseconds actual_frame_budget = stopwatch.GetFrameBudget();
EXPECT_EQ(frame_budget_90fps, actual_frame_budget);
}
TEST(Instrumentation, GetFrameBudgetFromUpdaterTest) {
MockRefreshRateUpdater updater;
fml::Milliseconds frame_budget_90fps = fml::RefreshRateToFrameBudget(90);
EXPECT_CALL(updater, GetFrameBudget())
.Times(1)
.WillOnce(Return(frame_budget_90fps));
Stopwatch stopwatch(updater);
fml::Milliseconds actual_frame_budget = stopwatch.GetFrameBudget();
EXPECT_EQ(frame_budget_90fps, actual_frame_budget);
}
} // namespace testing
} // namespace flutter