All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.facebook.testing.screenshot.ScreenshotRunner Maven / Gradle / Ivy

There is a newer version: 0.15.0
Show newest version
/**
 * Copyright (c) 2014-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

package com.facebook.testing.screenshot;

import android.app.Instrumentation;
import android.os.Bundle;

import com.facebook.testing.screenshot.internal.Registry;
import com.facebook.testing.screenshot.internal.ScreenshotImpl;

/**
 * The ScreenshotRunner needs to be called from the top level
 * Instrumentation runner before and after all the tests run.
 *
 * You don't need to call this directly if you're using {@code
 * ScreenshotTestRunner} as your instrumentation.
 */
public abstract class ScreenshotRunner {
  /**
   * Call this exactly once in your process before any screenshots are
   * generated.
   *
   * Typically this will be in {@code InstrumentationTestRunner#onCreate()}
   */
  public static void onCreate(Instrumentation instrumentation, Bundle arguments) {
    Registry registry = Registry.getRegistry();
    registry.instrumentation = instrumentation;
    registry.arguments = arguments;
  }

  /**
   * Call this exactly once after all your tests have run.
   *
   * Typically this can be in {@code InstrumentationTestRunner#finish()}
   */
  public static void onDestroy() {
    if (ScreenshotImpl.hasBeenCreated()) {
      ScreenshotImpl.getInstance().flush();
    }

    Registry.clear();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy