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

org.fest.assertions.api.android.app.InstrumentationActivityResultAssert Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
package org.fest.assertions.api.android.app;

import android.app.Instrumentation;
import android.content.Intent;
import org.fest.assertions.api.AbstractAssert;

import static org.fest.assertions.api.Assertions.assertThat;

/** Assertions for {@link Instrumentation.ActivityResult} instances. */
public class InstrumentationActivityResultAssert
    extends AbstractAssert {
  public InstrumentationActivityResultAssert(Instrumentation.ActivityResult actual) {
    super(actual, InstrumentationActivityResultAssert.class);
  }

  public InstrumentationActivityResultAssert hasResultCode(int code) {
    isNotNull();
    int actualCode = actual.getResultCode();
    assertThat(actualCode) //
        .overridingErrorMessage("Expected result code <%s> but was <%s>.", code, actualCode) //
        .isEqualTo(code);
    return this;
  }

  public InstrumentationActivityResultAssert hasResultData(Intent intent) {
    isNotNull();
    Intent actualIntent = actual.getResultData();
    assertThat(actualIntent) //
        .overridingErrorMessage("Expected result data <%s> but was <%s>.", intent, actualIntent) //
        .isEqualTo(intent);
    return this;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy