Skip to content

Commit

Permalink
Fix test for API 31
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqua committed Dec 13, 2021
1 parent 04fa20e commit 7910736
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.isoron.uhabits.acceptance.steps

import android.os.Build.VERSION.SDK_INT
import android.os.SystemClock.sleep
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiSelector
import org.isoron.uhabits.BaseUserInterfaceTest.Companion.device
Expand All @@ -35,11 +36,12 @@ fun exportFullBackup() {
clickMenu(SETTINGS)
clickText("Export full backup")
if (SDK_INT < 28) return
sleep(8000)
pressBack()
}

fun clearDownloadFolder() {
device.executeShellCommand("rm -rf /sdcard/Download/")
device.executeShellCommand("rm -rf /sdcard/Download")
}

fun clearBackupFolder() {
Expand All @@ -48,7 +50,7 @@ fun clearBackupFolder() {

fun copyBackupToDownloadFolder() {
device.executeShellCommand("mv $BACKUP_FOLDER $DOWNLOAD_FOLDER")
device.executeShellCommand("chown root $DOWNLOAD_FOLDER")
device.executeShellCommand("chmod -R a+rX $DOWNLOAD_FOLDER")
}

fun importBackupFromDownloadFolder() {
Expand Down Expand Up @@ -84,6 +86,10 @@ fun importBackupFromDownloadFolder() {
device.findObject(UiSelector().textContains("Android")).click()
device.findObject(UiSelector().textContains("Download")).click()
device.findObject(UiSelector().textContains("Loop")).click()
} else if (SDK_INT >= 31) {
device.click(50, 90) // Click menu button
device.findObject(UiSelector().textContains("Downloads")).click()
device.findObject(UiSelector().textContains("Loop")).click()
} else {
device.click(50, 90) // Click menu button
device.findObject(UiSelector().textContains("Download")).click()
Expand Down

0 comments on commit 7910736

Please sign in to comment.