All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fest.assertions.api.android.preference.SwitchPreferenceAssert Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
// 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