com.facebook.testing.screenshot.Screenshot Java Examples

The following examples show how to use com.facebook.testing.screenshot.Screenshot. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationTest.java    From CompactCalendarView with MIT License 6 votes vote down vote up
private void capture(final String name) {
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            compactCalendarView.requestLayout();
            ViewHelpers.setupView(mainContent)
                    .setExactHeightPx(mainContent.getHeight())
                    .setExactWidthPx(mainContent.getWidth())
                    .layout();
            safeSleep(200);
            Screenshot.snap(mainContent)
                    .setName(name)
                    .record();
        }
    });
}
 
Example #2
Source File: ScreenshotHelper.java    From Isometric with Apache License 2.0 5 votes vote down vote up
public static void measureAndScreenshotView(View view, int width, int height) {
    ViewHelpers.setupView(view)
            .setExactWidthPx(width)
            .setExactHeightPx(height)
            .layout();
    Screenshot.snap(view)
            .record();
}
 
Example #3
Source File: ScreenshotTest.java    From KataScreenshotAndroid with Apache License 2.0 5 votes vote down vote up
protected void compareScreenshot(View view, int height) {
  Context context = getInstrumentation().getTargetContext();
  WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  DisplayMetrics metrics = new DisplayMetrics();
  windowManager.getDefaultDisplay().getMetrics(metrics);
  ViewHelpers.setupView(view)
      .setExactHeightPx(context.getResources().getDimensionPixelSize(height))
      .setExactWidthPx(metrics.widthPixels)
      .layout();
  Screenshot.snap(view).record();
}
 
Example #4
Source File: ExampleScreenshotTest.java    From screenshot-tests-for-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefault() {
  Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
  LayoutInflater inflater = LayoutInflater.from(targetContext);
  LithoView view = (LithoView) inflater.inflate(R.layout.litho_view, null, false);

  view.setComponent(Example.create(view.getComponentContext()).build());

  ViewHelpers.setupView(view).setExactWidthDp(300).layout();
  Screenshot.snap(view).record();
}
 
Example #5
Source File: ImageRowScreenshotTest.java    From screenshot-tests-for-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefault() {
  Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
  LayoutInflater inflater = LayoutInflater.from(targetContext);
  LithoView view = (LithoView) inflater.inflate(R.layout.litho_view, null, false);

  view.setComponent(ImageRow.create(view.getComponentContext()).build());

  ViewHelpers.setupView(view).setExactWidthDp(300).layout();
  Screenshot.snap(view).record();
}
 
Example #6
Source File: PresenterActivityScreenshotTest.java    From edx-app-android with Apache License 2.0 5 votes vote down vote up
@After
public void after() {
    activity.runOnUiThread(() -> {
        Screenshot.snap(activity.findViewById(android.R.id.content)).setName(getClass().getName() + "_" + testName.getMethodName()).record();
    });

}
 
Example #7
Source File: LaunchScreenshotTests.java    From edx-app-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testScreenshot_recordLaunchActivity() throws Throwable {
    Activity activity = mActivityRule.getActivity();
    activity.runOnUiThread(() -> {
        Screenshot.snap(activity.findViewById(android.R.id.content)).setName(getClass().getName() + "_" + testName.getMethodName()).record();
    });
}
 
Example #8
Source File: ApplicationTest.java    From CompactCalendarView with MIT License 5 votes vote down vote up
private void takeScreenShot(final int height) {
    activityRule.getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            ViewHelpers.setupView(mainContent)
                    .setExactHeightDp(height)
                    .setExactWidthPx(mainContent.getWidth())
                    .layout();
        }
    });

    Screenshot.snap(mainContent)
            .record();
}
 
Example #9
Source File: BaseSnapshotTest.java    From Leanplum-Android-SDK with Apache License 2.0 4 votes vote down vote up
protected void snapshotView(@NonNull View view) {
  Screenshot.snap(view).setName(getSnapshotName()).record();
}
 
Example #10
Source File: ScreenshotTest.java    From KataScreenshotAndroid with Apache License 2.0 4 votes vote down vote up
protected void compareScreenshot(Activity activity) {
  Screenshot.snapActivity(activity).record();
}