diff --git a/app/src/androidTest/java/org/thoughtcrime/securesms/SignalInstrumentationApplicationContext.kt b/app/src/androidTest/java/org/thoughtcrime/securesms/SignalInstrumentationApplicationContext.kt index 49f7c3078b..485f9fafbc 100644 --- a/app/src/androidTest/java/org/thoughtcrime/securesms/SignalInstrumentationApplicationContext.kt +++ b/app/src/androidTest/java/org/thoughtcrime/securesms/SignalInstrumentationApplicationContext.kt @@ -35,4 +35,18 @@ class SignalInstrumentationApplicationContext : ApplicationContext() { LogDatabase.getInstance(this).logs.trimToSize() } } + + override fun beginJobLoop() = Unit + + /** + * Some of the jobs can interfere with some of the instrumentation tests. + * + * For example, we may try to create a release channel recipient while doing + * an import/backup test. + * + * This can be used to start the job loop if needed for tests that rely on it. + */ + fun beginJobLoopForTests() { + super.beginJobLoop() + } } diff --git a/app/src/androidTest/java/org/thoughtcrime/securesms/dependencies/InstrumentationApplicationDependencyProvider.kt b/app/src/androidTest/java/org/thoughtcrime/securesms/dependencies/InstrumentationApplicationDependencyProvider.kt index a883661547..ade9ad37b1 100644 --- a/app/src/androidTest/java/org/thoughtcrime/securesms/dependencies/InstrumentationApplicationDependencyProvider.kt +++ b/app/src/androidTest/java/org/thoughtcrime/securesms/dependencies/InstrumentationApplicationDependencyProvider.kt @@ -37,7 +37,7 @@ import java.util.Optional * * Handles setting up a mock web server for API calls, and provides mockable versions of [SignalServiceNetworkAccess]. */ -class InstrumentationApplicationDependencyProvider(application: Application, default: ApplicationDependencyProvider) : ApplicationDependencies.Provider by default { +class InstrumentationApplicationDependencyProvider(val application: Application, private val default: ApplicationDependencyProvider) : ApplicationDependencies.Provider by default { private val serviceTrustStore: TrustStore private val uncensoredConfiguration: SignalServiceConfiguration diff --git a/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java b/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java index d6c86e8445..fdcf7622d6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java +++ b/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java @@ -190,7 +190,7 @@ public class ApplicationContext extends MultiDexApplication implements AppForegr .addNonBlocking(this::initializeCleanup) .addNonBlocking(this::initializeGlideCodecs) .addNonBlocking(StorageSyncHelper::scheduleRoutineSync) - .addNonBlocking(() -> ApplicationDependencies.getJobManager().beginJobLoop()) + .addNonBlocking(this::beginJobLoop) .addNonBlocking(EmojiSource::refresh) .addNonBlocking(() -> ApplicationDependencies.getGiphyMp4Cache().onAppStart(this)) .addNonBlocking(this::ensureProfileUploaded) @@ -463,6 +463,11 @@ public class ApplicationContext extends MultiDexApplication implements AppForegr } } + @VisibleForTesting + protected void beginJobLoop() { + ApplicationDependencies.getJobManager().beginJobLoop(); + } + @WorkerThread private void initializeBlobProvider() { BlobProvider.getInstance().initialize(this);