mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Large tests: Make compatible with API 27
This commit is contained in:
3
.github/workflows/main.yml
vendored
3
.github/workflows/main.yml
vendored
@@ -30,6 +30,7 @@ jobs:
|
||||
AndroidTest:
|
||||
needs: Build
|
||||
runs-on: macOS-10.15
|
||||
timeout-minutes: 45
|
||||
strategy:
|
||||
matrix:
|
||||
api: [
|
||||
@@ -37,7 +38,7 @@ jobs:
|
||||
# 24, # Failing tests
|
||||
# 25, # Failing tests
|
||||
# 26, # Failing tests
|
||||
# 27, # Failing tests
|
||||
27,
|
||||
28,
|
||||
# 29, # Crashes constantly, see: https://issuetracker.google.com/issues/159732638
|
||||
# 30, # Not available yet
|
||||
|
||||
2
build.sh
2
build.sh
@@ -127,7 +127,7 @@ _run_instrumented_tests() {
|
||||
-r -e coverage true -e size $size \
|
||||
-w ${PACKAGE_NAME}.test/androidx.test.runner.AndroidJUnitRunner \
|
||||
| tee ${ANDROID_OUTPUTS_DIR}/instrument.txt
|
||||
if grep "\(INSTRUMENTATION_STATUS_CODE.*-1\|FAILURES\|ABORTED\|onError\|Error type\)" $ANDROID_OUTPUTS_DIR/instrument.txt; then
|
||||
if grep "\(INSTRUMENTATION_STATUS_CODE.*-1\|FAILURES\|ABORTED\|onError\|Error type\|crashed\)" $ANDROID_OUTPUTS_DIR/instrument.txt; then
|
||||
log_error "Some $size instrumented tests failed."
|
||||
log_error "Saving logcat: ${ANDROID_OUTPUTS_DIR}/logcat.txt..."
|
||||
$ADB logcat -d > ${ANDROID_OUTPUTS_DIR}/logcat.txt
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user