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

org.fest.assertions.api.android.widget.ToggleButtonAssert Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
// Copyright 2013 Square, Inc.
package org.fest.assertions.api.android.widget;

import android.widget.ToggleButton;

import static org.fest.assertions.api.Assertions.assertThat;

public class ToggleButtonAssert
    extends AbstractCompoundButtonAssert {
  public ToggleButtonAssert(ToggleButton actual) {
    super(actual, ToggleButtonAssert.class);
  }

  public ToggleButtonAssert hasOnText(CharSequence text) {
    isNotNull();
    CharSequence actualText = actual.getTextOn();
    assertThat(actualText) //
        .overridingErrorMessage("Expected 'on' text <%s> but was <%s>.", text, actualText) //
        .isEqualTo(text);
    return this;
  }

  public ToggleButtonAssert hasOnText(int resId) {
    isNotNull();
    return hasOnText(actual.getContext().getString(resId));
  }

  public ToggleButtonAssert hasOffText(CharSequence text) {
    isNotNull();
    CharSequence actualText = actual.getTextOff();
    assertThat(actualText) //
        .overridingErrorMessage("Expected 'off' text <%s> but was <%s>.", text, actualText) //
        .isEqualTo(text);
    return this;
  }

  public ToggleButtonAssert hasOffText(int resId) {
    isNotNull();
    return hasOffText(actual.getContext().getString(resId));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy