mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
967eeff86e
Summary: Add unit tests for Layout Animations. This first batch generates a random mutation, then animates it to completion. I found one issue with UPDATE+REMOVE+INSERT animation consistency. That shouldn't cause any crashes in production, but is a chance to improve consistency of mutations overall - and could in theory point to memory corruption, though it's somewhat unlikely. I ran with randomized seeds, found issues, fixed them, re-ran to ensure issues were fixed, rinsed and repeated. At the end I was able to run dozens of times (with random seeds) and found nothing. The next step is to repeatedly generate mutations that conflict with ongoing animations. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D28343750 fbshipit-source-id: c1c60d89a31be3ac05d57482f0af3c482b866abe
30 lines
579 B
C++
30 lines
579 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 <chrono>
|
|
|
|
class MockClock {
|
|
public:
|
|
typedef std::chrono::
|
|
time_point<std::chrono::steady_clock, std::chrono::nanoseconds>
|
|
time_point;
|
|
|
|
static time_point now() noexcept {
|
|
return time_;
|
|
}
|
|
|
|
template <typename TDuration>
|
|
static void advance_by(const TDuration duration) {
|
|
time_ += duration;
|
|
}
|
|
|
|
private:
|
|
static time_point time_;
|
|
};
|