org.fest.assertions.api.android.hardware.SensorEventAssert 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.hardware;
import android.hardware.SensorEvent;
import org.fest.assertions.api.AbstractAssert;
import static org.fest.assertions.api.Assertions.assertThat;
/** Assertions for {@link SensorEvent} instances. */
public class SensorEventAssert extends AbstractAssert {
public SensorEventAssert(SensorEvent actual) {
super(actual, SensorEventAssert.class);
}
public SensorEventAssert hasAccuracy(int accuracy) {
isNotNull();
int actualAccuracy = actual.accuracy;
assertThat(actualAccuracy) //
.overridingErrorMessage("Expected accuracy <%s> but was <%s>.", accuracy, actualAccuracy) //
.isEqualTo(accuracy);
return this;
}
public SensorEventAssert hasTimestamp(long timestamp) {
isNotNull();
long actualTimestamp = actual.timestamp;
assertThat(actualTimestamp) //
.overridingErrorMessage("Expected timestamp <%s> but was <%s>.", timestamp,
actualTimestamp) //
.isEqualTo(timestamp);
return this;
}
public SensorEventAssert hasValues(float[] values) {
isNotNull();
float[] actualValues = actual.values;
assertThat(actualValues) //
.overridingErrorMessage("Expected values <%s> but was <%s>.", values, actualValues) //
.isEqualTo(values);
return this;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy