mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: changelog: [internal] Add unit tests for `RuntimeScheduler::now` Reviewed By: JoshuaGross Differential Revision: D27763852 fbshipit-source-id: 1edec8e8338e9d9798b95c55d07114be05f555b8
42 lines
875 B
C++
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
|