Hush lite wallet for Android
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
920 B

package cash.z.ecc.android.test
import android.annotation.TargetApi
import android.content.Context
import android.os.Build
import android.os.PowerManager
import androidx.test.core.app.ApplicationProvider
import org.junit.Before
import java.lang.AssertionError
/**
* Subclass this for UI tests to ensure they run correctly. This helps when developers run tests
* against a physical device that might have gone to sleep.
*/
open class UiTestPrerequisites {
@Before
fun verifyScreenOn() {
if (!isScreenOn()) {
throw AssertionError("Screen must be on for UI tests to run") // $NON-NLS
}
}
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
private fun isScreenOn(): Boolean {
val powerService = ApplicationProvider.getApplicationContext<Context>()
.getSystemService(Context.POWER_SERVICE) as PowerManager
return powerService.isInteractive
}
}