Files
react-native/ReactCommon/react/renderer/runtimescheduler/tests/StubClock.h
T
Samuel SuslaandFacebook GitHub Bot e3a4de8b55 Add unit tests for RuntimeScheduler::now
Summary:
changelog: [internal]

Add unit tests for `RuntimeScheduler::now`

Reviewed By: JoshuaGross

Differential Revision: D27763852

fbshipit-source-id: 1edec8e8338e9d9798b95c55d07114be05f555b8
2021-04-15 02:44:13 -07:00

42 lines
875 B
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <react/renderer/runtimescheduler/RuntimeSchedulerClock.h>
#include <chrono>
namespace facebook::react {
class StubClock {
public:
RuntimeSchedulerTimePoint getNow() const {
return timePoint_;
}
void setTimePoint(RuntimeSchedulerTimePoint timePoint) {
timePoint_ = timePoint;
}
void setTimePoint(RuntimeSchedulerDuration duration) {
timePoint_ = RuntimeSchedulerTimePoint(duration);
}
RuntimeSchedulerTimePoint getTimePoint() {
return timePoint_;
}
void advanceTimeBy(RuntimeSchedulerDuration duration) {
timePoint_ += duration;
}
private:
RuntimeSchedulerTimePoint timePoint_;
};
} // namespace facebook::react