org.assertj.android.api.app.InstrumentationActivityResultAssert Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assertj-android Show documentation
Show all versions of assertj-android Show documentation
A set of AssertJ assertion helpers geared toward testing Android.
package org.assertj.android.api.app;
import android.app.Instrumentation;
import android.content.Intent;
import org.assertj.core.api.AbstractAssert;
import static org.assertj.core.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;
}
}