org.fest.assertions.api.android.animation.AbstractValueAnimatorAssert 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.animation;
import android.animation.ValueAnimator;
import static android.animation.ValueAnimator.INFINITE;
import static android.animation.ValueAnimator.RESTART;
import static android.animation.ValueAnimator.REVERSE;
import static org.fest.assertions.api.Assertions.assertThat;
public abstract class AbstractValueAnimatorAssert, A extends ValueAnimator>
extends AbstractAnimatorAssert {
protected AbstractValueAnimatorAssert(A actual, Class selfType) {
super(actual, selfType);
}
public S hasAnimatedFraction(float fraction) {
isNotNull();
float actualFraction = actual.getAnimatedFraction();
assertThat(actualFraction) //
.overridingErrorMessage("Expected animated fraction <%s> but was <%s>.", fraction,
actualFraction) //
.isEqualTo(fraction);
return myself;
}
public S hasAnimatedValue(Object value) {
isNotNull();
Object actualValue = actual.getAnimatedValue();
assertThat(actualValue) //
.overridingErrorMessage("Expected animated value <%s> but was <%s>.", value, actualValue) //
.isEqualTo(value);
return myself;
}
public S hasCurrentPlayTime(long time) {
isNotNull();
long actualTime = actual.getCurrentPlayTime();
assertThat(actualTime) //
.overridingErrorMessage("Expected current play time <%s> but was <%s>.", time,
actualTime) //
.isEqualTo(time);
return myself;
}
public S hasRepeatCount(int count) {
isNotNull();
int actualCount = actual.getRepeatCount();
assertThat(actualCount) //
.overridingErrorMessage("Expected repeat count <%s> but was <%s>.",
repeatCountToString(count), repeatCountToString(actualCount)) //
.isEqualTo(count);
return myself;
}
public S hasRepeatMode(int mode) {
isNotNull();
int actualMode = actual.getRepeatMode();
assertThat(actualMode) //
.overridingErrorMessage("Expected repeat mode <%s> but was <%s>.", repeatModeToString(mode),
repeatModeToString(actualMode)) //
.isEqualTo(mode);
return myself;
}
private static String repeatCountToString(int count) {
if (count == INFINITE) {
return "infinite";
}
return Integer.toString(count);
}
private static String repeatModeToString(int mode) {
switch (mode) {
case RESTART:
return "restart";
case REVERSE:
return "reverse";
default:
throw new IllegalArgumentException("Unknown repeat mode: " + mode);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy