public void resetRootViewForScreenshotTests() {
   if (mReactInstanceManager != null) {
     mReactInstanceManager.onDestroy();
     mReactInstanceManager = null;
   }
   mReactRootView = new ReactRootView(this);
   mScreenshotingFrameLayout.removeAllViews();
   mScreenshotingFrameLayout.addView(mReactRootView);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    overridePendingTransition(0, 0);

    // We wrap screenshot layout in another FrameLayout in order to handle custom dimensions of the
    // screenshot view set through {@link #setScreenshotDimensions}
    FrameLayout rootView = new FrameLayout(this);
    setContentView(rootView);

    mScreenshotingFrameLayout = new ScreenshotingFrameLayout(this);
    mScreenshotingFrameLayout.setId(ROOT_VIEW_ID);
    rootView.addView(mScreenshotingFrameLayout);

    mReactRootView = new ReactRootView(this);
    mScreenshotingFrameLayout.addView(mReactRootView);
  }
 public void setScreenshotDimensions(int width, int height) {
   mScreenshotingFrameLayout.setLayoutParams(new FrameLayout.LayoutParams(width, height));
 }
 public boolean isScreenshotReady() {
   return mScreenshotingFrameLayout.isScreenshotReady();
 }
 /**
  * Does not ensure that this is run on the UI thread or that the UI Looper is idle like {@link
  * ReactAppInstrumentationTestCase#getScreenshot()}. You probably want to use that instead.
  */
 public Bitmap getCurrentScreenshot() {
   return mScreenshotingFrameLayout.getLastDrawnBitmap();
 }