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#include "flutter/fml/time/chrono_timestamp_provider.h"
6
7#include "flutter/runtime/dart_timestamp_provider.h"
8
9#include <thread>
10
11#include "gtest/gtest.h"
12
13namespace fml {
14namespace {
15
16TEST(TimePoint, Control) {
17 EXPECT_LT(TimePoint::Min(), ChronoTicksSinceEpoch());
18 EXPECT_GT(TimePoint::Max(), ChronoTicksSinceEpoch());
19}
20
21TEST(TimePoint, DartClockIsMonotonic) {
22 using namespace std::chrono_literals;
23 const auto t1 = flutter::DartTimelineTicksSinceEpoch();
24 std::this_thread::sleep_for(d: 1us);
25 const auto t2 = flutter::DartTimelineTicksSinceEpoch();
26 std::this_thread::sleep_for(d: 1us);
27 const auto t3 = flutter::DartTimelineTicksSinceEpoch();
28 EXPECT_LT(TimePoint::Min(), t1);
29 EXPECT_LE(t1, t2);
30 EXPECT_LE(t2, t3);
31 EXPECT_LT(t3, TimePoint::Max());
32}
33
34} // namespace
35} // namespace fml
36

source code of flutter_engine/flutter/fml/time/time_point_unittest.cc