Large tests: Make compatible with API 27

This commit is contained in:
2021-04-25 19:22:32 -05:00
parent b561dfe90d
commit 2728c311d8
6 changed files with 12 additions and 5 deletions

View File

@@ -56,7 +56,8 @@ open class BaseUserInterfaceTest {
@After
@Throws(Exception::class)
fun tearDown() {
for (i in 0..9) device.pressBack()
device.pressBack()
device.pressBack()
}
@Throws(Exception::class)

View File

@@ -19,9 +19,11 @@
package org.isoron.uhabits.acceptance.steps
import android.os.Build.VERSION.SDK_INT
import androidx.test.uiautomator.UiSelector
import org.isoron.uhabits.BaseUserInterfaceTest.Companion.device
import org.isoron.uhabits.acceptance.steps.CommonSteps.clickText
import org.isoron.uhabits.acceptance.steps.CommonSteps.pressBack
import org.isoron.uhabits.acceptance.steps.ListHabitsSteps.MenuItem.SETTINGS
import org.isoron.uhabits.acceptance.steps.ListHabitsSteps.clickMenu
@@ -31,7 +33,8 @@ const val DOWNLOAD_FOLDER = "/sdcard/Download/"
fun exportFullBackup() {
clickMenu(SETTINGS)
clickText("Export full backup")
device.pressBack()
if (SDK_INT < 28) return
pressBack()
}
fun clearDownloadFolder() {

View File

@@ -120,10 +120,12 @@ object CommonSteps : BaseUserInterfaceTest() {
private fun verifyDisplaysView(className: String) {
Espresso.onView(ViewMatchers.withClassName(CoreMatchers.endsWith(className)))
.check(ViewAssertions.matches(ViewMatchers.isEnabled()))
device.waitForIdle()
}
fun verifyDoesNotDisplayText(text: String?) {
Espresso.onView(ViewMatchers.withText(text)).check(ViewAssertions.doesNotExist())
device.waitForIdle()
}
@Throws(Exception::class)

View File

@@ -110,7 +110,7 @@ fun Activity.showMessage(msg: String) {
fun Activity.showSendFileScreen(archiveFilename: String) {
val file = File(archiveFilename)
val fileUri = FileProvider.getUriForFile(this, "org.isoron.uhabits", file)
this.startActivity(
this.startActivitySafely(
Intent().apply {
action = Intent.ACTION_SEND
type = "application/zip"