org.fest.assertions.api.android.preference.SwitchPreferenceAssert 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.preference;
import android.preference.SwitchPreference;
import static org.fest.assertions.api.Assertions.assertThat;
/** Assertions for {@link SwitchPreference} instances. */
public class SwitchPreferenceAssert
extends AbstractTwoStatePreference {
public SwitchPreferenceAssert(SwitchPreference actual) {
super(actual, SwitchPreferenceAssert.class);
}
public SwitchPreferenceAssert hasSwitchTextOff(CharSequence text) {
isNotNull();
CharSequence actualText = actual.getSwitchTextOff();
assertThat(actualText) //
.overridingErrorMessage("Expected switch off text <%s> but was <%s>.", text, actualText) //
.isEqualTo(text);
return this;
}
public SwitchPreferenceAssert hasSwitchTextOff(int resId) {
isNotNull();
return hasSwitchTextOff(actual.getContext().getString(resId));
}
public SwitchPreferenceAssert hasSwitchTextOn(CharSequence text) {
isNotNull();
CharSequence actualText = actual.getSwitchTextOn();
assertThat(actualText) //
.overridingErrorMessage("Expected switch on text <%s> but was <%s>.", text, actualText) //
.isEqualTo(text);
return this;
}
public SwitchPreferenceAssert hasSwitchTextOn(int resId) {
isNotNull();
return hasSwitchTextOn(actual.getContext().getString(resId));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy