org.assertj.android.api.os.PowerManagerAssert Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assertj-android Show documentation
Show all versions of assertj-android Show documentation
A set of AssertJ assertion helpers geared toward testing Android.
// 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;
}
}