org.fest.assertions.api.android.os.AsyncTaskAssert Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fest-android Show documentation
Show all versions of fest-android Show documentation
A set of FEST assertion helpers geared toward testing Android.
// Copyright 2013 Square, Inc.
package org.fest.assertions.api.android.os;
import android.os.AsyncTask;
import org.fest.assertions.api.AbstractAssert;
import static org.fest.assertions.api.Assertions.assertThat;
/** Assertions for {@link AsyncTask} instances. */
public class AsyncTaskAssert extends AbstractAssert {
public AsyncTaskAssert(AsyncTask actual) {
super(actual, AsyncTaskAssert.class);
}
public AsyncTaskAssert hasStatus(AsyncTask.Status status) {
isNotNull();
AsyncTask.Status actualStatus = actual.getStatus();
assertThat(actualStatus) //
.overridingErrorMessage("Expected status <%s> but was <%s>.", status, actualStatus) //
.isEqualTo(status);
return this;
}
public AsyncTaskAssert isCancelled() {
isNotNull();
assertThat(actual.isCancelled()) //
.overridingErrorMessage("Expected to be cancelled but was not.") //
.isTrue();
return this;
}
public AsyncTaskAssert isNotCancelled() {
isNotNull();
assertThat(actual.isCancelled()) //
.overridingErrorMessage("Expected to not be cancelled but was.") //
.isFalse();
return this;
}
}