diff --git a/app/build.gradle b/app/build.gradle index a179fe9f9..d72191717 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -135,6 +135,10 @@ android { } } +ext { + work_version = '2.4.0' +} + dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.preference:preference:1.1.1' @@ -145,7 +149,7 @@ dependencies { implementation 'androidx.vectordrawable:vectordrawable:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.palette:palette:1.0.0' - implementation 'androidx.work:work-runtime:2.4.0' + implementation "androidx.work:work-runtime:$work_version" implementation 'com.google.android.material:material:1.1.0' @@ -177,6 +181,7 @@ dependencies { testImplementation 'org.hamcrest:hamcrest:2.2' testImplementation 'org.bouncycastle:bcprov-jdk15on:1.65' + androidTestImplementation 'androidx.arch.core:core-testing:2.1.0' androidTestImplementation 'androidx.test:core:1.3.0' androidTestImplementation 'androidx.test:runner:1.3.0' androidTestImplementation 'androidx.test:rules:1.3.0' @@ -184,6 +189,7 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' + androidTestImplementation "androidx.work:work-testing:$work_version" } checkstyle { diff --git a/app/src/androidTest/java/org/fdroid/fdroid/WorkManagerTestRule.java b/app/src/androidTest/java/org/fdroid/fdroid/WorkManagerTestRule.java new file mode 100644 index 000000000..a2091588b --- /dev/null +++ b/app/src/androidTest/java/org/fdroid/fdroid/WorkManagerTestRule.java @@ -0,0 +1,35 @@ +package org.fdroid.fdroid; + +import android.app.Instrumentation; +import android.content.Context; +import android.util.Log; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.work.Configuration; +import androidx.work.WorkManager; +import androidx.work.testing.SynchronousExecutor; +import androidx.work.testing.WorkManagerTestInitHelper; + +import org.junit.rules.TestWatcher; +import org.junit.runner.Description; + +public class WorkManagerTestRule extends TestWatcher { + private Context targetContext; + private Context testContext; + private Configuration configuration; + private WorkManager workManager; + + @Override + protected void starting(Description description) { + final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); + targetContext = instrumentation.getTargetContext(); + testContext = instrumentation.getContext(); + configuration = new Configuration.Builder() + .setMinimumLoggingLevel(Log.DEBUG) + .setExecutor(new SynchronousExecutor()) + .build(); + + WorkManagerTestInitHelper.initializeTestWorkManager(targetContext, configuration); + workManager = WorkManager.getInstance(targetContext); + } +} diff --git a/gradle/verification-keyring.gpg b/gradle/verification-keyring.gpg index f506bf277..6349fbeee 100644 Binary files a/gradle/verification-keyring.gpg and b/gradle/verification-keyring.gpg differ diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index d5aae5a02..5ce758fee 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -63,6 +63,7 @@ + @@ -86,7 +87,10 @@ - + + + + @@ -166,6 +170,11 @@ + + + + + @@ -648,6 +657,16 @@ + + + + + + + + + +