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

org.assertj.android.api.os.PowerManagerAssert Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
// Copyright 2013 Square, Inc.
package org.assertj.android.api.os;

import android.annotation.TargetApi;
import android.os.PowerManager;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.Assertions;

import static android.os.Build.VERSION_CODES.KITKAT_WATCH;

/** Assertions for {@link PowerManager} instances. */
public class PowerManagerAssert extends AbstractAssert {
  public PowerManagerAssert(PowerManager actual) {
    super(actual, PowerManagerAssert.class);
  }

  public PowerManagerAssert isScreenOn() {
    isNotNull();
    Assertions.assertThat(actual.isScreenOn()) //
        .overridingErrorMessage("Expected screen to be on but was off.") //
        .isTrue();
    return this;
  }

  public PowerManagerAssert isScreenOff() {
    isNotNull();
    Assertions.assertThat(actual.isScreenOn()) //
        .overridingErrorMessage("Expected screen to be off but was on.") //
        .isFalse();
    return this;
  }

  @TargetApi(KITKAT_WATCH)
  public PowerManagerAssert isInteractive() {
    isNotNull();
    Assertions.assertThat(actual.isInteractive()) //
        .overridingErrorMessage("Expected screen to interactive but was not interactive.") //
        .isTrue();
    return this;
  }

  @TargetApi(KITKAT_WATCH)
  public PowerManagerAssert isNotInteractive() {
    isNotNull();
    Assertions.assertThat(actual.isInteractive()) //
        .overridingErrorMessage("Expected screen to not be interactive but was interactive.") //
        .isFalse();
    return this;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy