@@ -0,0 +1,1642 @@
+/*%0A * Copyright (c) 2017-present, Facebook, Inc.%0A * All rights reserved.%0A *%0A * This source code is licensed under the BSD-style license found in the%0A * LICENSE file in the root directory of this source tree. An additional grant%0A * of patent rights can be found in the PATENTS file in the same directory.%0A */%0A%0Apackage com.facebook.litho.testing.espresso.rules;%0A%0Aimport android.support.test.InstrumentationRegistry;%0Aimport com.facebook.litho.dataflow.ChoreographerCompatImpl;%0Aimport com.facebook.litho.dataflow.DataFlowGraph;%0Aimport com.facebook.litho.dataflow.MockTimingSource;%0Aimport com.facebook.litho.dataflow.springs.SpringConfig;%0Aimport org.junit.rules.ExternalResource;%0A%0A/**%0A * A test rule for instrumentation and screenshot tests that need control over animation driving.%0A */%0Apublic class AnimationRunnerTestRule extends ExternalResource %7B%0A%0A  private MockTimingSource mFakeTimingSource;%0A%0A  @Override%0A  protected void before() throws Throwable %7B%0A    mFakeTimingSource = new MockTimingSource();%0A    mFakeTimingSource.start();%0A    DataFlowGraph.setInstance(DataFlowGraph.create(mFakeTimingSource));%0A    SpringConfig.defaultConfig = new SpringConfig(20, 10);%0A    ChoreographerCompatImpl.setInstance(mFakeTimingSource);%0A  %7D%0A%0A  /** Skip the given amount of frames */%0A  public void stepAnimationFrames(final int numFrames) %7B%0A    InstrumentationRegistry.getInstrumentation()%0A        .runOnMainSync(%0A            new Runnable() %7B%0A              @Override%0A              public void run() %7B%0A                mFakeTimingSource.step(numFrames);%0A              %7D%0A            %7D);%0A%0A    InstrumentationRegistry.getInstrumentation().waitForIdleSync();%0A  %7D%0A%7D%0A

create AnimationRunnerTestRule