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:
|
AndroidTest:
|
||||||
needs: Build
|
needs: Build
|
||||||
runs-on: macOS-10.15
|
runs-on: macOS-10.15
|
||||||
|
timeout-minutes: 45
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
api: [
|
api: [
|
||||||
@@ -37,7 +38,7 @@ jobs:
|
|||||||
# 24, # Failing tests
|
# 24, # Failing tests
|
||||||
# 25, # Failing tests
|
# 25, # Failing tests
|
||||||
# 26, # Failing tests
|
# 26, # Failing tests
|
||||||
# 27, # Failing tests
|
27,
|
||||||
28,
|
28,
|
||||||
# 29, # Crashes constantly, see: https://issuetracker.google.com/issues/159732638
|
# 29, # Crashes constantly, see: https://issuetracker.google.com/issues/159732638
|
||||||
# 30, # Not available yet
|
# 30, # Not available yet
|
||||||
|
|||||||
2
build.sh
2
build.sh
@@ -127,7 +127,7 @@ _run_instrumented_tests() {
|
|||||||
-r -e coverage true -e size $size \
|
-r -e coverage true -e size $size \
|
||||||
-w ${PACKAGE_NAME}.test/androidx.test.runner.AndroidJUnitRunner \
|
-w ${PACKAGE_NAME}.test/androidx.test.runner.AndroidJUnitRunner \
|
||||||
| tee ${ANDROID_OUTPUTS_DIR}/instrument.txt
|
| 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 "Some $size instrumented tests failed."
|
||||||
log_error "Saving logcat: ${ANDROID_OUTPUTS_DIR}/logcat.txt..."
|
log_error "Saving logcat: ${ANDROID_OUTPUTS_DIR}/logcat.txt..."
|
||||||
$ADB logcat -d > ${ANDROID_OUTPUTS_DIR}/logcat.txt
|
$ADB logcat -d > ${ANDROID_OUTPUTS_DIR}/logcat.txt
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ open class BaseUserInterfaceTest {
|
|||||||
@After
|
@After
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun tearDown() {
|
fun tearDown() {
|
||||||
for (i in 0..9) device.pressBack()
|
device.pressBack()
|
||||||
|
device.pressBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
|
|||||||
@@ -19,9 +19,11 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.acceptance.steps
|
package org.isoron.uhabits.acceptance.steps
|
||||||
|
|
||||||
|
import android.os.Build.VERSION.SDK_INT
|
||||||
import androidx.test.uiautomator.UiSelector
|
import androidx.test.uiautomator.UiSelector
|
||||||
import org.isoron.uhabits.BaseUserInterfaceTest.Companion.device
|
import org.isoron.uhabits.BaseUserInterfaceTest.Companion.device
|
||||||
import org.isoron.uhabits.acceptance.steps.CommonSteps.clickText
|
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.MenuItem.SETTINGS
|
||||||
import org.isoron.uhabits.acceptance.steps.ListHabitsSteps.clickMenu
|
import org.isoron.uhabits.acceptance.steps.ListHabitsSteps.clickMenu
|
||||||
|
|
||||||
@@ -31,7 +33,8 @@ const val DOWNLOAD_FOLDER = "/sdcard/Download/"
|
|||||||
fun exportFullBackup() {
|
fun exportFullBackup() {
|
||||||
clickMenu(SETTINGS)
|
clickMenu(SETTINGS)
|
||||||
clickText("Export full backup")
|
clickText("Export full backup")
|
||||||
device.pressBack()
|
if (SDK_INT < 28) return
|
||||||
|
pressBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearDownloadFolder() {
|
fun clearDownloadFolder() {
|
||||||
|
|||||||
@@ -120,10 +120,12 @@ object CommonSteps : BaseUserInterfaceTest() {
|
|||||||
private fun verifyDisplaysView(className: String) {
|
private fun verifyDisplaysView(className: String) {
|
||||||
Espresso.onView(ViewMatchers.withClassName(CoreMatchers.endsWith(className)))
|
Espresso.onView(ViewMatchers.withClassName(CoreMatchers.endsWith(className)))
|
||||||
.check(ViewAssertions.matches(ViewMatchers.isEnabled()))
|
.check(ViewAssertions.matches(ViewMatchers.isEnabled()))
|
||||||
|
device.waitForIdle()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun verifyDoesNotDisplayText(text: String?) {
|
fun verifyDoesNotDisplayText(text: String?) {
|
||||||
Espresso.onView(ViewMatchers.withText(text)).check(ViewAssertions.doesNotExist())
|
Espresso.onView(ViewMatchers.withText(text)).check(ViewAssertions.doesNotExist())
|
||||||
|
device.waitForIdle()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ fun Activity.showMessage(msg: String) {
|
|||||||
fun Activity.showSendFileScreen(archiveFilename: String) {
|
fun Activity.showSendFileScreen(archiveFilename: String) {
|
||||||
val file = File(archiveFilename)
|
val file = File(archiveFilename)
|
||||||
val fileUri = FileProvider.getUriForFile(this, "org.isoron.uhabits", file)
|
val fileUri = FileProvider.getUriForFile(this, "org.isoron.uhabits", file)
|
||||||
this.startActivity(
|
this.startActivitySafely(
|
||||||
Intent().apply {
|
Intent().apply {
|
||||||
action = Intent.ACTION_SEND
|
action = Intent.ACTION_SEND
|
||||||
type = "application/zip"
|
type = "application/zip"
|
||||||
|
|||||||
Reference in New Issue
Block a user